mardi 17 février 2015

How to pass model params when 2 models to same route

I am having trouble with getting the params of the user with multiple models to a route. At first I had this code:



App.IndexRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('user', params.id);
}
});


That worked fine and passed all user params.


However now I need data from the 'game' model. This code below successfully gets the 'game' data to the template but now I have no user params and I keep getting syntax errors when trying to put the code in to pass them.



App.IndexRoute = Ember.Route.extend({
model: function(params) {
return Ember.RSVP.hash({
game: store.find('game'),
user: store.find('user')
});
},
setupController: function(controller, models) {
var game = models.game;
var user = models.user;

controller.set('content', game);
controller.set('user', user);
}
});


I was wondering how I can have 2 models going to 1 route and the params for user also.


I also don't fully understand setupController and what I need to put in my index controller.


Thanks in advanced.





Aucun commentaire:

Enregistrer un commentaire