javascript - AngularJS: Filter ng-repeat based on certain properties -
this question has answer here:
i have simple problem can't find answers on stack.
i have data, so:
$scope.data = [ {name: 'foo', age: 19, job:'bartender', city: 'someplace'} {name: 'foo', age: 20, job:'something else', city: 'someplace'} {name: 'foo', age: 21, job:'another thing', city: 'someplace'} ]
you idea (except actual dataset 1000x , have 50 properties - api read i'm stuck i've got!).
my ng-repeat
builds table data, , have input allowing user filter.
let's want input filter name
, city
fields. (in real-world use, 10 fields). how do it?
i've seen things like:
<input ng-model="filterby.property"> <div ng-repeat="item in data | filter: filterby">
but won't work multiple, selective properties.
maybe
<input ng-model="filterby.name"> <input ng-model="filterby.city"> <div ng-repeat="item in data | filter:{name: filterby.name, city: filterby.city}"></div>
Comments
Post a Comment