Reputation: 63
I am having an issue when adding index to my table rows. I have assigned index value like this:
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef>#</mat-header-cell>
<mat-cell *matCellDef="let i = index"> {{i+1}} </mat-cell>
</ng-container>
This solution is working on one table but on the second table it is returning NaN. Does anyone knows how to fix this?
On the second table I am using expandable rows so I have added multiTemplateDataRows attribute. Everything else is the same. I am using Material Design v7.11
Upvotes: 4
Views: 2957
Reputation: 3931
As you are using multiTemplateDataRows
property , you can't use index. Instead you have to use dataIndex or renderIndex.
<mat-cell *matCellDef="let i = renderIndex;">{{i+1}}</mat-cell>
Upvotes: 18