ng-repeat :filter by single field
Specify the property (i.e. colour
) where you want the filter to be applied:
<div ng-repeat="product in products | filter:{ colour: by_colour }">
See the example on the filter page. Use an object, and set the color in the color property:
Search by color: <input type="text" ng-model="search.color"><div ng-repeat="product in products | filter:search">
You can filter by an object with a property matching the objects you have to filter on it:
app.controller('FooCtrl', function($scope) { $scope.products = [ { id: 1, name: 'test', color: 'red' }, { id: 2, name: 'bob', color: 'blue' } /*... etc... */ ];});
<div ng-repeat="product in products | filter: { color: 'red' }">
This can of course be passed in by variable, as Mark Rajcok suggested.