After applying the orderBy
on a table, the ordering is lost and the values of $index
are from the sorted array rather than the original one. For example, if you have an items
array with values
['orange', 'banana','potato','apple']
in your ng-repeat
, after sorting, they will be displayed as:
- apple $index = 0
- banana $index = 1
- orange $index = 2
- potato $index = 3
If you attempt to select multiple items between apple($index = 0)
and orange($index = 2)
, you might think this code would work:
for(index = 0; index <= 2; index++)
console.log(items[index])
But it will actually print : [orange, banana, potato]
; not [apple, banana, orange]
.
I'm searching for a method to determine the indexes within the displayed array post orderBy, any suggestions?
EDIT: Let's say that on the interface you have sorted the items
and then selected apple followed by orange:
✓ apple
banana
✓ orange
potato
I am interested in knowing the items
between those two selections, so I can choose all in-between, such as banana
.