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
Your issue is that ng-repeat is scope isolated. As a result you can't refer to the internal list that is being managed by ng-repeat from your controller/directive.
As a result there are 2 options
Bind the filtered list to ng-repeat from your controller/directive, so you maintain the filtered list.
//in your controller
$scope.filteredItems = $filter('yourFilter')($scope.items,$scope.searchText);
$scope.$watch('searchText', function(newValue){
$scope.filteredItems = $filter('yourFilter')($scope.items, newValue);
});
//in your view
{{item.id}}
{{item.name}}
Perform the filter again in your controller/directive
$scope.toggleAll() {
var items = $filter('yourFilter')($scope.items, $scope.searchText);
for(var i in items){
//set your selected property
}
}