Reputation: 493
I am using angular2 -datatable.
I am not able to display correct row no.s in the corresponding rows.
The datatable starts counting from one again when the user moves to the next page using paginator.
My html code:
<tbody>
<tr *ngFor="let item of mf.data; let i =index">
<td>
{{i+1}}
</td>
<td>{{ item.name }}</td>
<td>{{item.department}}</td>
<td >{{item.category}}</td>
</tr>
</tbody>
Upvotes: 0
Views: 4326
Reputation: 38191
try {{data.indexOf(item) + 1}}
, here I suppose data
is the variable you bind to <table>
by <table [mfData]="data | filter "
this will get the original index from array of data.
Upvotes: 2
Reputation: 5332
You need to calculate it with currentPage
(current page number) and itemsPerPage
(number of item to show per page):
{{ itemsPerPage * (currentPage - 1) + i + 1 }}
Upvotes: 1