如何从被调用组件内部访问MatDialogConfig?

时间:2018-04-05 15:09:01

标签: angular-material2

我在我的水疗中心使用MatDialog,需要将MatDialogConfig传递给已调用的组件。有什么办法吗?

1 个答案:

答案 0 :(得分:2)

您可以使用componentInstance的{​​{1}}。只需获得对话框的参考,即可获得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;
}