根据行行角材料表中的组件实例

问题描述 投票:0回答:1
 <!-- Position Column -->
  <ng-container matColumnDef="position">
    <th mat-header-cell *matHeaderCellDef> No. </th>
    <td mat-cell *matCellDef="let element"> <app-my-component [position]="element.position" ></app-my-component> </td>
  </ng-container>

image of my table

你好,我想访问matRow

内部的组件实例

https://stackblitz.com/edit/angular-mmuf6a

我已经使用主机directive侦听器创建了一个行on click,并尝试使用component函数在我的行中获取ng.probe

有更好的方法吗?

angular angular-directive mat-table
1个回答
0
投票

另一种可能的解决方案是使用@ViewChildren()装饰器获取放置在表组件内部的所有自定义组件的列表。

© www.soinside.com 2019 - 2024. All rights reserved.