Skip to content

Inability to use $index #231

@ornic

Description

@ornic

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions