user2952265
user2952265

Reputation: 1630

AngularJS - How to filter a bunch of certain IDs?

I want to create a filter that hides e.g. three certain IDs given.

My data object look like that:

$scope.subtree = [{id: 1},{id: 2},{id: 3},{id: 4},{id: 5},{id: 6},{id: 6}]

I get the command to hide:

[{id: 1},{id: 4},{id: 6}]

Template

<ul>

   <li ng-repeat="node in subtree"> 
        <p>node.id </p>
   </li>

<ul>

Upvotes: 0

Views: 83

Answers (1)

pazo
pazo

Reputation: 56

Use filters, or a function on a scope.

data-ng-repeat="node in subtree | idFilter:[1,4,6]"

data-ng-repeat="node in subtree | filter:hideIds([1,4,6])"

Something like this

Upvotes: 3

Related Questions