I am using the MatTable
component from Angular Material to make a dynamic data table.
I need to get the current position of a row. I can easily get the row on which the user clicked but I am unable to know its current position in the list (which depends on sort/filtering/pagination).
Any idea?
in your
mat-cell
you can get index like*ngFor
as belowUpdate from Angular 5 use also
index as i
index
: number: The index of the current item in the iterable.first
: boolean: True when the item is the first item in the iterable.last
: boolean: True when the item is the last item in the iterable.even
: boolean: True when the item has an even index in the iterable.odd
: boolean: True when the item has an odd index in the iterable.Are you using angularjs or angular2? your title says angularjs but your tags and post say otherwise.
angular2
angularjs
edit: I saw your comments, does this answer help you out? Is there an index property with CDK data table or Material2 data table?