Angular:如何在.open()中设置dialog-component的参数?

时间:2017-11-13 09:11:04

标签: angular parameters constructor dialog components

对话框的组件:

constructor(@Inject(MAT_DIALOG_DATA) 
  public data: any, 
  public dialogRef: MatDialogRef<MyDialogComponent>,
  @Optional() public dialogtitle: string ) {}

致电部分:

openMyDialog(somedata: string){
    const myDialogRef = this.dialog.open(MyDialogComponent, {data: somedata});
   }

如何将可选参数“dialogtitle”的数据放在那里?

1 个答案:

答案 0 :(得分:0)

我猜你正在使用棱角分明的材料?

constructor(public dialogRef: MatDialogRef<MyDialogComponent>,
  @Optional() @Inject(MAT_DIALOG_DATA) public dialogtitle: string ) {}