how to define index in angular material table

后端 未结 5 878
栀梦
栀梦 2020-12-01 10:16

how should I define an index variable when angular material table is used as ngFor is not used in this table.

I did search for it in the documentation but index is

5条回答
  •  粉色の甜心
    2020-12-01 10:36

    For those who are facing problem with keeping the right index when using pagination which table has more than 1 page. It can be especially important when you have editable element, thus you're using a routerLink to add/edit/delete selected elements.

    
     Title
     
      

    As well as

    
    

    In essence, i + (paginator.pageIndex * paginator.pageSize) is the solution, but it counts from 0. If you'd like to index from 1, simply make it (i+1) + (paginator.pageIndex * paginator.pageSize). Worth to note is that you really need the #paginator and [pageSize]="VALUE".

提交回复
热议问题