角度材质对话框数据传递?

问题描述 投票:0回答:1

在Angular材质使用中,我需要将某种ID传递给Material提供的对话框。虽然我需要跟踪它的结束事件。怎么可能这样做?

angular angular-material
1个回答
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
    });
  }
© www.soinside.com 2019 - 2024. All rights reserved.