Reputation: 5313
Why when adding setupController
to a route the model
value returned from the model
hook is null
?
http://jsbin.com/pahuno/1/edit
I know i could work around it by setting up the model
value in the setupController
but I want to understand what is the problem
Upvotes: 0
Views: 144
Reputation: 8744
When you use a hook, such as setupController
or renderTemplate
, you are preventing Ember from handling the default case. Make a call to the default method:
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
},
setupController: function(controller, model) {
this._super(controller, model);
}
});
From a comment in the Ember source:
This method is called with the controller for the current route and the model supplied by the
model
hook.By default, the
setupController
hook sets themodel
property of the controller to themodel
. If you implement thesetupController
hook in your Route, it will prevent this default behavior. If you want to preserve that behavior when implementing yoursetupController
function, make sure to call_super
:
Upvotes: 3