# Non-context-switching #each with itemView and itemController

**URL:** <https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116>\
**Category:** Uncategorized\
**Created:** [January 21, 2015, 11:42am UTC](https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116 "2015-01-21T11:42:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmk](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nmk/32/15747_2.png) [@nmk](https://discuss.emberjs.com/u/nmk)\
**Post date:** [January 21, 2015, 11:42am UTC](https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116/1 "2015-01-21T11:42:17Z")

</div>

I am updating our app to Ember 1.9.1 and Handlebars 2.0. So far I have been rendering collections like this: [JS Bin - Collaborative JavaScript Debugging](http://jsbin.com/qasiwowafu/1/edit?html,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}}
{{/each}}

```

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!

---

<div class="post-metadata">

**Author:** ![tcjr](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tcjr/32/14655_2.png) [@tcjr](https://discuss.emberjs.com/u/tcjr)\
**Post date:** [January 21, 2015, 5:48pm UTC](https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116/2 "2015-01-21T17:48:19Z")

</div>

I think this discussion might help you: [What is a good way to do this in Ember 2.0? (No itemController, no ArrayController)](http://discuss.emberjs.com/t/what-is-a-good-way-to-do-this-in-ember-2-0-no-itemcontroller-no-arraycontroller/6649)

---

<div class="post-metadata">

**Author:** ![mitchlloyd](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mitchlloyd/32/14502_2.png) [@mitchlloyd](https://discuss.emberjs.com/u/mitchlloyd)\
**Post date:** [January 22, 2015, 5:28pm UTC](https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116/3 "2015-01-22T17:28:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nmk](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nmk/32/15747_2.png) [@nmk](https://discuss.emberjs.com/u/nmk)\
**Post date:** [February 6, 2015, 8:03pm UTC](https://discuss.emberjs.com/t/non-context-switching-each-with-itemview-and-itemcontroller/7116/4 "2015-02-06T20:03:37Z")

</div>

@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.
