I am currently working on an Angular 4 application and I am facing the task of displaying a specific component in a new child window. After researching for a solution (I am not interested in using routing by URL as my server always redirects to index with window.open('some URL')), I came across this helpful example on StackBlitz: StackBlitz Example
In the provided example, they are utilizing CdkPortal
. However, I encountered an issue as it seems cdk portal is not available in angular 4 (an error message stating '
@angular/cdk/portal"' has no exported member 'CdkPortal'
was displayed).
Although I attempted to replicate the same example since it perfectly aligns with my requirements, it doesn't seem to work with my angular version.
Is there an equivalent example that can be used for Angular 4?
ADDITIONAL
The example includes a code snippet to display the window:
<window *ngIf="showPortal">
<h2>Hello world from another window!!</h2>
<button (click)="this.showPortal = false">Close me!</button>
</window>
This raises the question if it's possible to add another component within the main component being attached in the portal. For instance:
<window *ngIf="showPortal">
<my-other-component [currentValue]="someValue"></my-other-component>
</window>
If such functionality is achievable, will the added component function correctly?