Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

itemController in ArrayController vs #each

Tags:

ember.js

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?

like image 783
RyanHirsch Avatar asked Jun 06 '13 19:06

RyanHirsch


Video Answer


1 Answers

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.

like image 193
Sebastian Seilund Avatar answered Sep 22 '22 18:09

Sebastian Seilund