I would like to use my custom filter with ngRepeat directive. Here is what I have
HTML:
<div ng-app="menuApp">
<ul ng-controller="MenuCtrl">
<li ng-repeat="item in menuItems | rootCategories">
{{item.Name}}
</li>
</ul>
</div>
JS:
angular.module('menuApp', [])
.filter('rootCategories', function() {
return function(item) {
return item.Parent == 0;
};
});
function MenuCtrl($scope) {
$scope.menuItems = [{ "Id": 1, "Name": "Sweep", "Parent": 0 }];
/*
$scope.rootCategories = function(item) {
return item.Parent == 0;
};
*/
};
I do not want to use the commented out way to filter my items, because the real filter will be complicated than in the provided example. For some reasons input parameter "item" is not defined, therefore I see nothing. Could you tell me what is wrong? Thank you.