New window doesn't recognize the app (see )
new-window.component.ts
@Component({
selector: 'app-new-window',
template: `
<h1>New Window Component</h1>
`,
})
export class NewWindowComponent {
// component logic
}
open-window.component.ts
@Component({
selector: 'app-open-window',
template: `
<button (click)="openNewWindow()">Open New Window</button>
`,
})
export class OpenWindowComponent {
private newWindow: Window | null = null;
openNewWindow() {
// Open a new browser window
this.newWindow = window.open('', '_blank');
if (this.newWindow) {
this.newWindow.document.open();
this.newWindow.document.write('<app-root></app-root>');
this.newWindow.document.close();
}
}
ngOnDestroy() {
// Close the new window when the component is destroyed
if (this.newWindow) {
this.newWindow.close();
}
}
}
How can I pass the new component in the new window and display the content of it ("New Window Component")