在角度材质中初始化MdDialog,而不是从构造函数初始化MdDialog

时间:2017-09-11 06:54:44

标签: angular typescript angular-material2

我正在试用角度材料中提到的md-dialog

https://material.angular.io/components/dialog/examples

constructor(public dialog: MdDialog) {}

openDialog(): void {
let dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
  width: '250px',
  data: { name: this.name, animal: this.animal }
});

dialogRef.afterClosed().subscribe(result => {
  console.log('The dialog was closed');
  this.animal = result;
});
}

它工作正常,我的问题是我无法使用构造函数初始化MdDialog

是否有某些方法可以初始化MdDialog并使用类似这样的内容

let dialogRef = new MdDialog()

0 个答案:

没有答案