1.12.0 Each Context's


#1

Wondering if somebody can help me with a context issue in ember 1.12.0. Asked the issue on the ember slack yesterday but it was buried pretty fast. Hoping i’ll have some better luck here.

I have an each that looks like this

{{#each someArrayOfObjects itemController='someCTRL' as |item| }}
    <div>item.name<div>
{{/each}}

When I use this syntax with the item controller i loose the context of item. I would prefer not to litter my itemController with every property i need. Dug around on the webs and found that i can use the with syntax. Ember 1.12.x changes this syntax so my new each looks like so

{{#each someArrayOfObjects itemController='someCTRL' as |item| }}
    {{#with foo as |item|}}
	    <div>foo.name<div>
    {{/with}}
{{/each}}

But this doesn’t work. I dont get any errors, my refs just wont render. Any ideas what im doing wrong?


#2

You probably will want to replace the concept of ‘itemController’ with a component. So, have a component that handles all the necessary logic and render it for each item in the array:

{{#each model as |item|}} {{new-component componentModel=item}} {{/each}}