I cant figure out how to get an index with Angular 6 and PrimeNG turbo table.
this is my best guess on how it should work.
<p-table [value]="timecards">
<ng-template pTemplate="body" let-timecard let-i="index">
<tr><td>{{ i }}</td><td>{{ timecard.value }}</td></tr>
</ng-template>
</p-table>
But I have also tried this
<p-table>
<ng-template pTemplate="body" ngFor let-timecard let-i="index" [ngForOf]="timecards>
<tr><td>{{ i }}</td><td>{{ timecard.value }}</td></tr>
</ng-template>
</p-table>
And this
<p-table [value]="timecards">
<ng-template pTemplate="body" ngFor let-timecard let-i="index" [ngForOf]="timecards>
<tr><td>{{ i }}</td><td>{{ timecard.value }}</td></tr>
</ng-template>
</p-table>
And several other combinations. I can't get any of them to work.
The property you are looking for is let-rowIndex as described by the PrimeNG TurboTable documentation:
<p-table [value]="timecards">
<ng-template pTemplate="body" let-timecard let-rowIndex="rowIndex">
<tr><td>{{ rowIndex }}</td><td>{{ timecard.value }}</td></tr>
</ng-template>
</p-table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With