jeudi 16 avril 2015

Ember.js: Iterating through multiple models set on controller

I want to declare two models to be loaded by my controller.


I am not using the model,beforeModel, or afterModel hooks because:



  1. I don't have to implement loading routes/templates

  2. I can load each model independently in the page (like lazy loading)


I am using the setupController hook in my route as so:



setupController: function(controller, model) {
var that = this;

controller.set('model', {
stations: that.store.find('station'),
packages: that.store.find('package'),
});
}


My controller is an Ember.Controller.


In order to iterate through these models in Handlebars I have to use model.stations.content.content which makes me think I am doing something wrong:



{{#each station in model.stations.content.content}}
// .....
{{/each}}


Is there a better way to set these models on the controller or use a different controller type or something?


Aucun commentaire:

Enregistrer un commentaire