If I have a controller with a $scope property that is an object with other properties rather than an array, how can I properly filter the ng-repeat set in AngularJS?
Check out this JSFiddle example: http://jsfiddle.net/ZfGx4/110/
This is how the controller looks:
function HelloCntl($scope, $filter) {
$scope.friends = {
john: {
name: 'John',
phone: '555-1276'
},
mary: {
name: 'Mary',
phone: '800-BIG-MARY'
},
mike: {
name: 'Mike',
phone: '500-4321'
},
adam: {
Name: 'Adam',
phone:'100-5678'
},
julie:{
name:'Julie',
phone: '900-8765'
}
};
}
And here is the template:
<div ng:app>
<div ng-controller="HelloCntl">
<input placeholder="Type to filter" ng-model="query">
<ul>
<li ng-repeat="(id, friend) in friends | filter:query">
<Span>{{friend.name}} @ {{friend.phone}}</span>
</li>
</ul>
</div>
</div>