As you know after orderBy
table loses its ordering and the $index
value is from the sorted array, not from the original array. So if you pass an items
array ['orange', 'banana','potato','apple']
to your ng-repeat
, after an orderBy
on the UI you will see them like this:
- apple $index = 0
- banana $index = 1
- orange $index = 2
- potato $index = 3
And if you now want to multi select items between apple($index = 0)
and orange($index = 2)
you might think that this will work:
for(index = 0; index <= 2; index++)
console.log(items[index])
which is wrong, it will print : [orange, banana, potato]
; not [apple, banana, orange]
.
I am looking a way to get the interval indexes of the displayed array after an orderBy, any ideas?
EDIT: To clarify, assume that on UI you have sorted items
and then you select apple and then select orange:
✓ apple
banana
✓ orange
potato
I want a way to know the items
in between those two selected, so that I can select all in between, in our case banana
.