M_F*_*and 6 angular-material2 angular
我在 spa 中使用 MatDialog,需要将 MatDialogConfig 传递给已调用的组件。有什么办法吗?
您可以使用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;
}
Run Code Online (Sandbox Code Playgroud)
对话框组件:
export class MyDialogComponent implements OnInit {
// Rename the property to whatever you want it to be
dialogConfig: MatDialogConfig;
ngOnInit() {
console.dir(`Dialog config: ${this.dialogConfig}`);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9450 次 |
| 最近记录: |