I need to open a component using the method open(MyComponent, myConfig)
of the class MatDialog but with a @Input()
added to the opened component. How can I do that?
Use the data
property to pass the wanted datas.
constructor(private dialog: MatDialog){}
this.diaog.open(YOUR_COMPONENT, {
data: {} // What you want
... // Others properties
});
Then in YOUR_COMPONENT:
constructor(@Inject(MAT_DIALOG_DATA) public data: any) {
console.log(this.data);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.