Reputation: 1513
I am trying to loop through two different models on a single route. What is best practice to do this?
Currently I am trying:
App.IndexRoute = Ember.Route.extend({
model: function(){
return App.Player.find();
},
setupController: function(controller, model){
controller.set('eventRounds', App.eventRound.find());
}
});
And looping though it with:
{{#each eventRounds}}
<tr>
<td>{{ player_1 }}</td>
<td>{{ player_2 }}</td>
</tr>
{{/each}}
But the setupController seems to be breaking the first model as well.
Thanks!
Upvotes: 0
Views: 94
Reputation: 1463
The default setupController
hook sets the model
property of the associated controller to the route handler's model.
When you define it manually, it will override the default behaviour.
So in your setupController, call this._super()
or set the model
manually, before you do your stuff.
App.IndexRoute = Ember.Route.extend({
model: function(){
return App.Player.find();
},
setupController: function(controller, model){
controller.set('model', model);
controller.set('eventRounds', App.eventRound.find());
}
});
Upvotes: 1