在Angular材质用法中,我需要将某种ID传递给Material提供的对话框。虽然我需要跟踪其关闭事件。这怎么可能呢?
答案 0 :(得分:0)
第一个构造函数:
import { MatDialog} from '@angular/material';
import { YOUR COMPONENT YOU NEED TO RENDER IN MAT POPUP } from 'COMPONENT PATH HERE';
内部类构造函数:
constructor(public dialog: MatDialog) { }
要传递数据时:
openViewdDialog(data: any): void {
const dialogRef = this.dialog.open(YOUR COMPONENT WHICH NEED TO BE OPENED, {
width: '850px', // What ever the width of popup
data: { data } //data you want to pass to the popup
});
dialogRef.afterClosed().subscribe(result => {
// Whatever you need to do when the popup is closed
});
}