Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I want to search in column name or number only, currently i'm only 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>
share|improve this question
    
What does this mean more specifically? Toggle which column you search or match either column? If it is the latter you will need a custom filter – charlietfl 12 hours ago

Create a custom filter to 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 is test object and list is your current array you want to return a 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
};
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.