filtering based on multpiple value
HTML
<div ng-app="myApp">
<div ng-controller="myCntrl">
<label>Search</label>
<input ng-model="query" type="text" placeholder="Search for name or producer"/>
<table>
<tr>
<td>Name</td>
<td>Producer</td>
</tr>
<tr ng-repeat="item in products | customFilter: query ">
<td>{{item.author}}</td>
<td>{{item.title}}</td>
</tr>
</table>
<div/>
</div>
JavaScript
angular.module('myApp', [])
. filter('customFilter', function() {
return function(product,query) {
var out = [];
angular.forEach(product,function(value,key){
if(value['author'].indexOf(query)>-1 || value['title'].indexOf(query)>-1)
{
out.push(value)
}
})
return out;
}
})
.controller("myCntrl",function($scope){
$scope.query="";
$scope.products=[
{
"author" : "Herbert Schildt",
"title" : "Java",
"id":"1",
},{
"author" : "Cecelia Ahern",
"title" : "P.S I Love you",
"id":"2",
},{
"author" : "Martin",
"title" : "Song of ice and fire",
"id":"3,
},{
"author" : "Rowling",
"title" : "HarryPotter",
"id":"4",
},
{
"author" : "ABC",
"title" : "java",
"id":"5",
}
]
});