get index of row in angular material table v5

后端 未结 8 797
别那么骄傲
别那么骄傲 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:25

    Using indexOf is an enormous waste of resources. The right way is initializing a variable with index's value, like this:

    
       Num. 
      {{i + 1}}
    
    

    https://material.angular.io/components/table/examples

    UPDATE:

    If you are using pagination the index can be calculated this way:

    
       Num. 
      
      {{this.paginator.pageIndex == 0 ? i + 1 : 1 + i + this.paginator.pageIndex * this.paginator.pageSize}}
      
    
    

提交回复
热议问题