Two different instances of the same filter are causing unexpected outputs in my ng-repeat display. One instance is scoped at the app level and defined in the module, while the other is scoped at the controller level.
Interestingly, when using the filter for the same ng-repeat display, it generates two different parameters. The app-wide filter takes all objects as a parameter, whereas the controller-scoped filter only takes each item individually. Why does this happen?
Snippet of code
Local controller-scoped filter
$scope.localFilter = function(item){
console.log(item); //Single item
return true;
};
//Implementation:
<div ng-repeat="post in currentStation.posts | filter:$parent.localFilter">
App-wide filter
angular.module('customFilters', [])
//Used to filter data items, often in an ng-repeat.
.filter('globalFilter', function() {
return function(items)
{
console.log(items); //multiple items
};
});
//Implementation:
<div ng-repeat="post in currentStation.posts | globalFilter">