Emberjs equivalent to Angular filter ng search query

Is there an easy way to apply a search filter like angular:

<input type="text" ng-model="resultFilter" placeholder="Search">

<ul>
    <li ng-repeat="result in results | filter:resultFilter">{{result.name}}</li>
</ul>

this filters the result by what is ever typed into the input field, creating an unusually simple search function. Is there a simple equivalent of amberge or one of those simple anuglarjs perks?

+4
source share
1 answer

You can use Ember.computed.filterto dynamically filter your model.

App.IndexController = Ember.Controller.extend({
   searchKeyword: '',

   searchResults: Ember.computed.filter('model', function(model) {
       return model.filterProperty('name', this.get('searchKeyword'));
   }).property('model', 'name')
});

with sample template

{{input type="text" valueBinding="searchKeyword"}}

<ul>
{{#each result in searchResults}}
   <li>{{result.name}}</li>
{{/each}}
</ul>
0
source

All Articles