【问题标题】:Angular Material Menu per mat-row on click to the row单击该行时,每个垫子行的角度材料菜单
【发布时间】:2022-10-06 20:45:01
【问题描述】:

我有这个材料表:

<table mat-table
       [dataSource]=\"dataSource\">

  <ng-container matColumnDef=\"id\">
    <th mat-header-cell
        *matHeaderCellDef>ID</th>
    <td mat-cell
        *matCellDef=\"let report\"
        [innerText]=\"report.id\"></td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef=\"[\'id\']\"></tr>
  <tr mat-row *matRowDef=\"let row; columns: [\'id\'];\"></tr>

</table>

我正在尝试为mat-row 实现[matMenuTrigger]。每行都有自己的mat-menu,属性为report

问题是我能做到

<tr mat-header-row *matHeaderRowDef=\"[\'id\']\" [matMenuTriggerFor]=\"rowMenu\"></tr>

但是我没有对reportMenu 的引用,因为我只能在一些matColumnDef 中定义reportMenu

  <ng-container matColumnDef=\"id\">
    <th mat-header-cell
        *matHeaderCellDef>ID</th>
    <td mat-cell
        *matCellDef=\"let report\"
        [innerText]=\"report.id\"></td>

    <mat-menu #reportMenu=\"matMenu\">
        {{ report.name }}
    </mat-menu>

  </ng-container>

当我引用mat-row 时,我没有引用report 本身。我该如何解决这个问题?

    标签: angular angular-material angular-material-table


    【解决方案1】:

    把你的菜单放在桌子外面。别担心,它会起作用的。

    然后,follow the documentation 为您的菜单提供数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-05
      • 2018-12-27
      • 2021-02-15
      • 2018-04-08
      • 2022-11-18
      • 1970-01-01
      • 2022-12-07
      • 2018-06-22
      相关资源
      最近更新 更多