kei kei - 1 month ago 14
Javascript Question

AngularJS filtering on ngRepeat on items without key

My array looks like this:

[
{name:'John',IsManager:true},
{name:'Terry'},
{name:'Sam'},
{name:'Andy'}
]


I'm trying to get it to display all the people that don't have the
IsManager
property:
Terry, Sam, and Andy


Here's what I have so far:


<span ng-repeat="user in Users | filter: {?????}">
{{user.name}}
</span>


How do I set up this filter? Can this be done without using a custom filter?

Answer
<span ng-repeat="user in Users | filter:filterOutNonManagers">
  {{user.name}}
</span>

$scope.filterOutNonManagers = function(user) {
    return !user.IsManager;
};