mardi 17 février 2015

How do I expose a component via block params in Ember 1.10 + HTMLBars

With block params, I thought the following would work to expose a component to a nested control without need of the _yield hack.



{{#my-component as |myparam|}}
{{log myparam}}
{{/my-component}}


This does not appear to work, as this log returns undefined.


I'm using ember-cli 0.1.15 ember 1.10.0 and ember-cli-htmlbars 0.7.4. Is there something I need to do to enable block params, or is this not the correct notation?


UPDATE


For an example usage, consider a flexible carousel with slides and control buttons.



{{#carousel-component as |carousel|}}
{{#slide-component}}
<button {{action "nextSlide" target=carousel}}>Next</button>
{{/slide}}
{{/carousel-component}}


And to be specific, this is an attempt at solving this use case strictly using the new block params syntax available in Ember 1.10.





Aucun commentaire:

Enregistrer un commentaire