vendredi 20 février 2015

Make data from store app-wide available?

I've got a base-route encapsulating all other routes in my application.


I'd like to make the categories I retrieve from the store via this.store.find('category') available everywhere in my application.


I tried retrieving it in the base-controller with this code:



import Ember from 'ember';

export default Ember.ArrayController.extend({
// retrieve all categories as they are needed in several places
categories: function() {
return this.get('store').find('category');
}
});


and creating an alias from child-controllers via:



categories: Ember.computed.alias('controllers.base.categories')


but it gives this error-message:



Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed function () { return this.get('store').find('category'); }



How can I solve my problem?


Aucun commentaire:

Enregistrer un commentaire