您可以使用
componentInstance
属于
MatDialogRef<T>
。只需获取对话框的引用即可获取
MatDialogRef
:
打开对话框的方法:
openDialog(dialogConfig: MatDialogConfig) {
let dialogRef = this.dialog.open(MyDialogComponent);
// You can rename the dialogConfig instance to whatever you want. See the next code snippet for more info.
dialogRef.componentInstance.dialogConfig = dialogConfig;
}
对话框组件:
export class MyDialogComponent implements OnInit {
// Rename the property to whatever you want it to be
dialogConfig: MatDialogConfig;
ngOnInit() {
console.dir(`Dialog config: ${this.dialogConfig}`);
}
}