dimanche 21 août 2016

How Angular filter work? how to simulate one like that in Ember.js

What is logic behind angular filter? We use angular filter in below way

var users = [
  {
    name: "lokesh",
    age: 25
  },
 {
    name: "john",
    age: 20
  }
]

<input type="text" ng-model="search">
<div ng-repeat="user in users | filter:search">
    
</div>

Is there any such filter in Ember.js or how to a such filter in plain javascript. Filter should return objects which has that user typed word. Moreover that filter should be like a independent component. It should work with any number of properties in the object

var search = "lokesh";
users.filter(function (user) {
  return user.name == search || user.age == search;
});

The above filter works for 2 properties name and age. I want a filter that can work with any number of properties. More over Filter should match partial strings aswell unlike above example which checks for ==




Aucun commentaire:

Enregistrer un commentaire