在Angular材质使用中,我需要将某种ID传递给Material提供的对话框。虽然我需要跟踪它的结束事件。怎么可能这样做?
首先在构造函数中:
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
});
}