Angular 打开材料弹出窗口时如何将数据传递到组件

Angular 打开材料弹出窗口时如何将数据传递到组件,angular,typescript,angular-material,Angular,Typescript,Angular Material,我有一个用于弹出窗口(AngularMaterial对话框)的组件包装器。在这个组件中,我使用ngComponentOutlet动态显示子组件 popup-shell.component.html <mat-dialog-content class="mat-typography popup-shell"> <div class="popup-shell__container"> <ng-contain

我有一个用于弹出窗口(AngularMaterial对话框)的组件包装器。在这个组件中,我使用ngComponentOutlet动态显示子组件

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>
在PopupShellComponent中打开数据时,如何将数据传递给UserPopupComponent


我知道我可以将injector与ngComponentOutlet一起使用,但我无法制作一个工作版本。

请阅读下面的博客,它将对您非常有帮助

您已经注入了
@Inject(MAT\u DIALOG\u DATA)公共数据
。如果您
console.log(data)
,您没有看到传递的数据吗?@eko打开它时,我需要将User1、User2等传递给UserComponent。现在它只是静态组件,您检查过吗:?
constructor(public dialogRef: MatDialogRef<PopupShellComponent>, @Inject(MAT_DIALOG_DATA) public data) {}
 constructor(private dialog: MatDialog) {}
 
 openPopup() {
     const dialogRef = this.dialog.open(PopupShellComponent, {
          data: { component: UserPopupComponent },
     });
 }