vendredi 30 octobre 2015

Ember component and dynamic attributes over iteration

How can I add support to my custom Ember component for appending dynamic attributes and also action? I have my custom component as

{{my-radiobutton name='myName' value='RadioButton1' selection=this.selectedRadio}}

Now I want to iterate over API response and have dynamic attributes in my template as well as action support as below;

{{#each model.myApi as |myApi|}}
{{#if someCondition}}
{{my-radiobutton name='myName_{{myApi.someId}}' value='someAction_{{myApi.someId}}' selection=this.selectedRadio {{action 'actionClicked'}}}}
{{else}}
{{my-radiobutton name='myName_{{myApi.someId}}' value='someAction_{{myApi.someId}}' selection=this.selectedRadio {{action 'actionClicked'}}}}
{{/if}}
{{/each}}

Is it possible to do that?

PS: I do not have control over the custom component my-radiobutton, since it is kind of common/external, so I'll prefer anything in the template or my controller




Aucun commentaire:

Enregistrer un commentaire