I have an array of objects that I\'m displaying in my Angular app using ng-repeat
. I\'m filtering out items using filter
and the value of a search
Angular filters create a new array. So in order to perform an action on the filtered items you're going to have to capture the new array.
Something like:
$scope.toggleAll() {
var filteredItems = $filter('filter')($scope.items, $scope.searchValue);
for(var i in filteredItems) {
...
}
}
If you don't want to filter twice you'll have to filter the array yourself every time searchValue
changes and ng-repeat
over that filtered array, ng-change is useful in that case.