【问题标题】:Mat-table inside mat-dialog垫子对话框内的垫子表
【发布时间】:2021-11-09 07:57:22
【问题描述】:

我想在对话框中创建一个表格,这样当用户单击链接时,他们可以在对话框中看到该表格。

我创建了 mat-table 和对话框。唯一的问题是 dialog.open() 函数将组件作为参数,因此对话框再次显示所有页面。有没有办法给它表格ID或其他东西,以便我只能在其中显示特定表格?

constructor(public dialog: MatDialog) { }
  
openDialog() {
  this.dialog.open(UserProfileComponent);
}

html <a value="case1" (click)="openDialog()">Click for details</a>

【问题讨论】:

  • 创建一个带有表格的组件,然后将该组件用于 mat-dialog,并在参数中传递表格的数据

标签: angular typescript angular-material


【解决方案1】:

ts 中打开弹出窗口:

this.dialog.open(DialogOverviewExampleDialog, {
  data: {id: someId}
});

在弹出窗口中:

  constructor(
    public dialogRef: MatDialogRef<DialogOverviewExampleDialog>,
    @Inject(MAT_DIALOG_DATA) public data: DialogData) {
    if(data.id) {
     // do something
    }
  }

【讨论】:

    猜你喜欢
    • 2023-01-26
    • 1970-01-01
    • 2018-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-22
    相关资源
    最近更新 更多