RyanHirsch
RyanHirsch

Reputation: 1847

itemController in ArrayController vs #each

Following along with the Getting Started Guide I have this http://jsbin.com/enutit/2/edit

My question is how come I can't remove the itemController from this each helper

<ul id="todo-list">
    {{#each controller itemController="todo"}}
        <li {{bindAttr class="isCompleted:completed isEditing:editing"}}>

and then add

itemController: 'todo',

to Todos.TodosController and have it work?

Upvotes: 10

Views: 4531

Answers (1)

Sebastian Seilund
Sebastian Seilund

Reputation: 454

Because the controller's properties are not the same as the {{each}} helper's properties.

{{each}} internally creates an instance of Ember.Handlebars.EachView to display each item in the Todos.TodosController's content property. It is this view that needs the itemController property so that it can create a new Todos.TodoController (note the singular form) instance for each child view.

Upvotes: 8

Related Questions