Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inability to use $index #231

Open
ornic opened this issue Feb 9, 2020 · 0 comments
Open

Inability to use $index #231

ornic opened this issue Feb 9, 2020 · 0 comments

Comments

@ornic
Copy link

ornic commented Feb 9, 2020

Since vs-repeat uses new trimmed collection it is impossible to use $index to refer element in original collection.

This problem can be solved by adding index inside the elements of original collection. For example, by adding this into refresh() function after originalLength = originalCollection.length;:

for (var _originalIndex = 0; _originalIndex < originalLength; _originalIndex++) {
    originalCollection[_originalIndex]._originalIndex = _originalIndex;
}

and then use it like this:

<div class="list-group" style="max-height: 80vh; overflow-y: auto;" vs-repeat>
   <div ng-repeat="group in $ctrl.coding.itemGroups track by group._originalIndex">
   ...
   </div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant