0

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.

Oleg Shchegolev
  • 176
  • 1
  • 11

1 Answers1

-1

Please read following blog it will be very helpful for you Using Mat Dialog

ISK
  • 85
  • 1
  • 9