Reputation: 13
This is a question about Ember fundamentals.
Let's consider the following code from the Transitioning to Show Only Incomplete Todos step of the official Ember Getting Started guide.
Todos.TodosActiveRoute = Ember.Route.extend({
model: function(){
return this.store.filter('todo', function(todo) {
return !todo.get('isCompleted');
});
},
renderTemplate: function(controller) {
this.render('todos/index', {controller: controller});
}
});
this.render
is defining the passed object controller
as its controller. This makes sense as far as it goes, but... why?
The application (seems to) work if we call this.render
with only the template name argument:
renderTemplate: function(controller) {
this.render('todos/index');
}
The renderTemplate documentation states that it uses the route's controller by default, and that its controller
argument is also set to the route's controller. The pattern in the tutorial seems to explicitly declare default behavior. What's going on here?
Upvotes: 1
Views: 716
Reputation: 47367
There are three possible causes,
Trek did March 16 2013, https://github.com/emberjs/website/commit/0f2af23799ee2ba3c643303fb96e8b72026f8e7f#diff-750a8e7208fb50dc62974ff56234d69e
And it looks like the functionality was added January 10, 2013 by nragaz https://github.com/emberjs/ember.js/commit/dbe5b4fbcb26fc030cd4fb9fa5ae586217f20a4e
So it looks like I was wrong about #1, and it was probably #2.
Upvotes: 1