Created
May 4, 2014 23:01
-
-
Save brancusi/1e41b769c3ef0312fc0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is in the appliation route: | |
setupController:function(controller, model) { | |
this._super(controller, model); | |
controller.set('itemCollection', this.filterable(['ingredient', 'recipe'])); | |
}, | |
//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