javascript - filter in specific multiple expressions angular js -
i want search in column name or number only, i'm searching in column name.
<input type="text" ng-model="test.name" placeholder="start typing..">
my expressions,
<tr ng-repeat="x in names | filter:test | limitto:totaldisplayed"> <td>{{ x.name }}</td> <td>{{ x.number}}</td> <td>{{ x.city }}</td> <td>{{ x.country }}</td> </tr>
create custom filter accomplish this.
html
<input type="text" ng-model="test.name" placeholder="start typing.."> <tr ng-repeat="x in names | myfilter: test"> <td>{{ x.name }}</td> <td>{{ x.number}}</td> <td>{{ x.city }}</td> <td>{{ x.country }}</td> </tr>
js filter
angular.module('myapp').filter('myfilter', function () { return function (list, input) { //input test object , list current array want return filtered array var myarray = []; list.foreach(function(o, i){ if(o.name.indexof(input.name) > -1 || o.number.indexof(input.name) > -1 ) myarray.push(o); }); return myarray }; });
Comments
Post a Comment