Ember.js: Which controller is responsible?
What I have
POD structure ember-cli. I have nested routes and therefore the following folder structure:
|
|_pods
|_items
|_index
| |_controller.js
| |_route.js
| |_template.hbs
|_item
|_controller.js
I load all of my model's post items into the items / index / route.js hook model. In my index template, I am iterating over all elements from the element model.
{{#each model as |item|}}
...
{{/each}}
This works great. Now I want to call some properties from the alpha (singular) controller, so I added itemController-Properties to each helper:
{{#each model itemController='items.item' as |item|}}
now i can access the properties in my template for every element like {{item.myTestMethod}}
that defined in the alpha controller.
What is the problem?
But for some reason, the other parts between each loop are no longer available (for example {{item.title}}
, which is a property of the model). In addition, the Ember-Inspector will show me two more entries in the "View Tree" -Tab, one for each item in each loop.
Can anyone explain this to me?
Controllers no longer have proxy properties. You need to fully qualify the property you wish to access. The model is now a property model
on the controller (which is what it is now).
Property on model
{{item.model.title}}
Property on controller
{{item.fooProp}}