Search code examples
angularjsangularjs-directiveangularjs-ng-repeat

How to iterate over a collection of objects already filtered by ng-repeat filters


I have a collection of objects that AngularJS filters by a text search within a title property on each object.

After this filter has run, I am left with a set of items that matches this filter.

I would like to iterate over this subset of the list, after clicking a button, and change a property on the items that match this filter.

Is there an easy way to do this in AngularJS, or am I going to be doing this outside Angular and then updating the state manually in the controller?


Solution

  • It appears that within an ng-repeat you can do the following

    item in items | filter:x as results will store the fragment of the repeated items as results, but only after the items have been processed through the filter.