How to start component actions from a template inserted into the Ember.js component block form?

I want to activate component actions from a template inserted into a block form component as follows:

{{#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 action!!! </p> {{/block-component}} 

Block parameters included in Ember 1.10.0 can help me with this? Or is this requirement impossible?

+6
source share
1 answer

With the new block parameters in 1.10.0, this can be done by doing the following:

 {{#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 action!!! </p> {{/block-component}} 

Pay attention to the purpose of the action specified by the block parameter.

The component block template should contain the following:

 {{ yield this }} 

It simply passes the component itself, which will be used as the block parameter for any template using this component.

+11
source

Source: https://habr.com/ru/post/982455/


All Articles