skip to Main Content

I am trying to apply filter in list view .Whenever I typed anything in input field it filter my list .I am able to filter when I write username which is visible to user .example when I write “pa” it sort my list and display only one row .that is correct.but when I write on “keyword filter” which is not visible to user it doesn’t filter .In other words when I type “Angular js” on second input field (“keyword filter”) ..It should display pab..Because “pab” have Angular js keyword .

here is my code
http://plnkr.co/edit/TccgJydcZNkXQGpnbbP0?p=preview

// Code goes here

angular.module('myApp', [])
  .controller('myCtrl', function($scope){

  $scope.users = [

    {firstname: 'john', lastname: 'smith',

                keywords: ["HTML", "CSS", "JavaScript", "jQuery", "Photoshop"]

    },
    {firstname: 'pab', lastname: 'due',
             keywords: ["Ruby on Rails", "PostgreSQL", "AngularJS", "Node.js"]

    },
    {firstname: 'bob', lastname: 'rand',            keywords: ["java", "php", "test", "jira"]
}

  ];

});

2

Answers


  1. In your ng-repeat you are not filtering after your keyword input – you missed it. Just include it as follows:

    <div ng-repeat="user in users | filter:userSearch | filter:{ keywords: keyword }">
    
    Login or Signup to reply.
  2. you just need to add the the same ng-model on the second input :

    ng-model="userSearch"
    
    <body ng-controller='myCtrl'>
      <div>
        <div>
          <input type="text" placeholder="username search" ng-model="userSearch">
        </div>
        <br>
        <div>
          <input type="text" placeholder="keyword search" ng-model="userSearch">
        </div>
      </div>
    

    plunker: http://plnkr.co/edit/Nqp45xwrZqPLIWDtjGvQ?p=preview

    hope helps good luck.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search