mercredi 4 février 2015

Emberjs - Setting multiple models in a single route

I have an Emberjs app that contains a dashboard on the main page, which is loaded by the /browse route. I need to select multiple models in the browse route, so I can assign them to several views I have on the page.


I'm able to retrieve the models using the code below, but I feel like I'm doing something wrong--even though the data is available within the respective template, I'm not sure how to reference the models outside of the templates.


How do I specify the model I need when I call setupController for each template on the dashboard? Do I even need to call setupController? I'm really trying to understand selecting, assigning, and managing models in Emberjs, so any advice is greatly apprectiated!



App.BrowseRoute = Ember.Route.extend({
model: function () {
return new Ember.RSVP.hash({
sort: this.store.find('sort'),
feature: this.store.find('feature'),
category: this.store.find('category'),
activity: this.store.find('activity')
});
},
setupController: function (controller, model) {
this.controllerFor('sort').set('model', this.sort);
},
setupController: function (controller, model) {
this.controllerFor('feature').set('model', this.feature);
},
setupController: function (controller, model) {
this.controllerFor('category').set('model', this.category);
},
setupController: function (controller, model) {
this.controllerFor('activity').set('model', this.activity);
}
});




Aucun commentaire:

Enregistrer un commentaire