简体   繁体   English

在 mat-dialog 中填充组件的输入

[英]Populate Input for component inside mat-dialog

Currently we have like 5-10 different dialogs and we add data using @Inject ( @Inject(MAT_DIALOG_DATA) private data: DialogData, )目前我们有 5-10 个不同的对话框,我们使用 @Inject 添加数据( @Inject(MAT_DIALOG_DATA) private data: DialogData,

this.dialog.open(MyComponent, {
  data: { data: this.dataToPass }
});

But I was kind of curious if there is another way?但我有点好奇是否还有其他方法? Would love to have it similar to this:希望有类似这样的:

this.dialog.open(MyComponent, {
  input1: { this.dataToPass },
  input2: { this.moreDataToPass }
});

Any Ideas?有任何想法吗?

try like this试试这样

this.MyComponent_dialog_ref= this.dialog.open( MyComponent );
this.MyComponent_dialog_ref.componentInstance.input1= this.dataToPass;
this.MyComponent_dialog_ref.componentInstance.input2= this.moreDataToPass;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM