I have been having some confusion in regards to the Ember.Route model vs. setupController. I have an example app here:
http://jsbin.com/ihakop/5/edit
I am wondering why it is that I need to add the following (see inline comment)
App.AppsShowRoute = Ember.Route.extend({
model: function(params) {
return App.LtiApp.find(params.id);
},
setupController: function(controller, model) {
controller.set('reviews', App.Review.find());
// Why is this line needed? Shouldn't it have the model
// already on the controller?
controller.set('model', model);
}
});
Shouldn't the model already be on the controller?
This is a good question. This behaviour was introduced with RC4. Have a look at this blog post for explanation. The recommendation of the Ember guys is to add a call to _super()
:
App.AppsShowRoute = Ember.Route.extend({
model: function(params) {
return App.LtiApp.find(params.id);
},
setupController: function(controller, model) {
this._super(controller, model);
controller.set('reviews', App.Review.find());
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With