get index of row in angular material table v5

后端 未结 8 706
别那么骄傲
别那么骄傲 2020-12-08 19:43

I\'m trying to get the index of row in table, in html, which has been implemented using angular material v5.2. Is there any method available to get the index?

The co

相关标签:
8条回答
  • 2020-12-08 20:32

    I know this post is old but the above solution didn't work for me. instead if let i = index; try let i = dataIndex for latest version of mat-table check this solution. Don't know if it's just for expandable table though

    0 讨论(0)
  • 2020-12-08 20:32

    Anyone using Angular6+ should use let i = dataIndex instead of let i = index as explained in this Github issue.

    Here's the HTML snippet

    <ng-container matColumnDef="position">
      <th mat-header-cell *matHeaderCellDef mat-sort-header> Num. </th>
      <td mat-cell *matCellDef="let element; let i = dataIndex">{{i + 1}}</td>
    </ng-container>
    
    0 讨论(0)
提交回复
热议问题