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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -