Eg: if the array is reversed via a filter, then $index is currently the location in the filtered array while the new $originalIndex should be index of the pre-filtered array.
And this would hold if the array was filtered?
i.e.
{{ i in [1,2,5,6,9,10,13,4,8] | even}}
would give you scopes as such:
{i: 2, $index: 0, $originalIndex: 1}
{i: 6, $index: 1, $originalIndex: 3}
{i: 10, $index: 2, $originalIndex: 5}
{i: 4, $index: 3, $originalIndex: 7}
{i: 8, $index: 4, $originalIndex: 8}
?
Would this be better suited for a custom directive which could examine the ngRepeat expression and figure it out for you? I feel like this would introduce a performance hit or a change to the filter API that you wouldn't want to impose on a majority of users who wouldn't find this useful?
Yeah, it's probably a performance hit. A custom directive that populate the ng-repeat child scope with $originalIndex? Such as:
<div ng-repeat="" ng-add-original-index></div>
Yeah, that will process the ng-repeat expression for the scope variable to
look at and the original collection, then just uses
originalCollection.indexOf(scopeVariable) or some such to find the original
index.
On Fri, Oct 25, 2013 at 9:07 AM, Eddie Huang [email protected]:
Yeah, it's probably a performance hit. A custom directive that populate
the ng-repeat child scope with $originalIndex? Such as:tHubhttps://github.com/angular/angular.js/issues/4268#issuecomment-27104731
.
:+1:
This would be very helpful.
I really need this!
Please add this feature.
This wold be very useful for orderBy as well.
this feature is still opened? Unless it's added, How can I work around this ?
:+1:
Yeah!! We need this feature :+1:
Really helpful feature to implement!
:+1:
:+1:
Really helpful feature to implement!
:+1:
:+1:
:+1:
A nice to have
Hi,
you can do this using indexOf() and the right datas on input and output
ng-repeat="list in data.switch | filter: data.cb1 | orderBy:['NO_ELEVATION','-POSITION_Y'] "
and
ng-click="doSecondaryAction(data.switch.indexOf(list))">More Info
Most helpful comment
Hi,
you can do this using indexOf() and the right datas on input and output
ng-repeat="list in data.switch | filter: data.cb1 | orderBy:['NO_ELEVATION','-POSITION_Y'] "
and
ng-click="doSecondaryAction(data.switch.indexOf(list))">More Info