I have a component wrapper for popups (Angular Material MatDialog). In this component I am using ngComponentOutlet to dynamically display the children components.
popup-shell.component.html
<mat-dialog-content class="mat-typography popup-shell">
<div class="popup-shell__container">
<ng-container *ngComponentOutlet="data.component"></ng-container>
</div>
</mat-dialog-content>
popup-shell.component.ts
constructor(public dialogRef: MatDialogRef<PopupShellComponent>, @Inject(MAT_DIALOG_DATA) public data) {}
When angular open popup, I pass information about which popup should be opened in the data field.
constructor(private dialog: MatDialog) {}
openPopup() {
const dialogRef = this.dialog.open(PopupShellComponent, {
data: { component: UserPopupComponent },
});
}
How can I pass data to UserPopupComponent when I open it in PopupShellComponent?
I know that I can use injector with ngComponentOutlet, but I couldn't make a working version.