如何从块形式组件 Ember.js 中插入的模板触发组件的操作?

How to fire component's actions from template inserted in block-form component Ember.js?

我想像这样从块形式组件中插入的模板触发组件的操作:

{{#block-component}}
   <p> HTML inserted in block form </p>
   <p> How trigger a action from block-component (not your parent) from this scope? </p>
   <p {{action 'actionFromBlockComponent'}}> Fire component's action!!! </p>
{{/block-component}}

Ember 1.10.0 中启用的块参数可以帮助我解决这个问题吗?或者这个需求是不可能的?

使用 1.10.0 中的新块参数,可以通过执行以下操作实现:

{{#block-component as |component|}}
    <p> HTML inserted in block form </p>
    <p> How trigger a action from block-component (not your parent) from this scope? </p>
    <p {{action 'actionFromBlockComponent' target=component}}> Fire component's action!!! </p>
{{/block-component}}

注意设置为块参数的操作目标。

块组件的模板应包含以下内容:

{{ yield this }}

它只是传递组件本身,以用作使用该组件的任何模板的块参数。