0

I have that code:

<label>Ages: <input type="text" ng-model="objProp2AgesFilter" /></label><br />
<table>
  <thead>
     <tr>
       <th>Name</th>
     </tr>
  </thead>
  <tbody>
     <tr ng-repeat="p in items">
       <td>{{p.name}}</td>
     </tr>
  </tbody>
</table>

items array looks like:

[{ 
  name: 'tst1',
  ages: [1,2,3]
},{ 
  name: 'tst2',
  ages: [2,3,4]
}]

How to filter that items, whose contain value e.g. 4 in the ages array ?

1
  • You must write a custom filter. Commented Nov 25, 2014 at 8:51

1 Answer 1

3
<tr ng-repeat="p in items | filter:hasAge4">

And in the controller:

$scope.hasAge4 = function(item) {
    return item.ages.indexOf(4) >= 0;
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.