Non-context-switching #each with itemView and itemController


I am updating our app to Ember 1.9.1 and Handlebars 2.0. So far I have been rendering collections like this:,js,output

Things to note:

  • the itemController property in the array controller is needed as the included filter works on a property of the item controller instead of the model directly;
  • each child view has the correct model, controller and view set as can be verified in the Ember Inspector.

How can I convert this to the non-context-switching variety of the each helper?

My first guess would be

{{#each person in filteredPeople}}
  {{render "person" person}}

This does not work correctly because the itemController property of the parent causes person to be an instance of PersonController instead of the underlying object. So in the view hierarchy I get an instance of PersonController nested inside of an instance of PersonController.

Many thanks in advance!


I think this discussion might help you: What is a good way to do this in Ember 2.0? (No itemController, no ArrayController)


ItemController and render are also falling out of favor so I would avoid both of those.

In this case it looks like your itemController can be replaced by rendering a component inside of each.


@mitchlloyd The use of a controller would not solve the problem of using itemController properties for, e.g. sorting in the parent arrayController.

@tcjr The discussion is useful for learning what might come in Ember 2.0 but as far as I can see it offers no concrete solution to the problem at hand.