当前,我们有5-10个不同的对话框,我们使用@Inject(@Inject(MAT_DIALOG_DATA) private data: DialogData,
)添加数据
this.dialog.open(MyComponent, {
data: { data: this.dataToPass }
});
但是我有点好奇是否还有其他方法? 很乐意拥有与此类似的内容:
this.dialog.open(MyComponent, {
input1: { this.dataToPass },
input2: { this.moreDataToPass }
});
有什么想法吗?
答案 0 :(得分:0)
尝试这样
this.MyComponent_dialog_ref= this.dialog.open( MyComponent );
this.MyComponent_dialog_ref.componentInstance.input1= this.dataToPass;
this.MyComponent_dialog_ref.componentInstance.input2= this.moreDataToPass;