As I understad, a template in emberjs gets it's data from controller. So, it's a controller's job to get hold of model
data and present it to the template.
The docs here associate a model with a route like this:
App.FavoritesRoute = Ember.Route.extend({
model: function() {
// the model is an Array of all of the posts
return App.Post.find();
}
});
In this case and ArrayController
is automatically generated.
However, there's also the setupController
function. So, can we also do this :
App.FavoritesRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('model', App.Post.find());
}
});
as the first example given here do?
Do the two ways do the same thing?