Skip to content

Instantly share code, notes, and snippets.

@alexspeller
Forked from brancusi/gist:1e41b769c3ef0312fc0d
Last active August 29, 2015 14:00
Show Gist options
  • Save alexspeller/e7f16963348f1d753851 to your computer and use it in GitHub Desktop.
Save alexspeller/e7f16963348f1d753851 to your computer and use it in GitHub Desktop.
//This is in the appliation route:
setupController:function(controller, model) {
this._super(controller, model);
this.filterable(['ingredient', 'recipe']).then(function(array) {
controller.set('itemCollection', array)
});
},
//This doesn't work
filterable:function(types){
return this.store.find('item').then(function(collection){
return collection.filter(function(item){
return types.contains(item.get('typeTag'));
});
});
}
//This works but is not filtered properly
filterable:function(types){
return this.store.find('item').
}
...
//This is in the controller
items:function(){
return this.get('itemCollection');
}.property('itemCollection.@each'),
...
//In the template. Not valid with the filtering cause items is a promise
{{#each items}}
{{this}}
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment