Access parent context from ember component block

I am trying to understand how blocks work with ember components. With the following, I expect project.name to be displayed for each loop.

// components/block-test.js
export default Ember.Component.extend({});

// index.hbs
{{#each project in projects}}
    {{#block-test}}
        {{project.name}}
    {{/block-test}}
{{/each}}

But when I use this template project.name is not displayed. Is this the expected behavior, and if so, how can I change it to make the above code work?

+4
source share
1 answer
Component

intentionally isolated, transfers everything you want to use (you do not need to exit if you transfer it)

{{#block-test project=project}}
    --{{project.name}}--
{{/block-test}}

No component template

 --apple--
 --dog--
 --piano--

With exit

Component Template

--{{yield}}--

Component usage

{{#block-test}}
    {{project.name}}
{{/block-test}}


 --apple--
 --dog--
 --piano--
+4
source

All Articles