Ember / Handlebars: How to write the attribute str

2019-09-06 01:40发布

问题:

For example:

<img src="{{profile.avatar}}"/>

Do I really have to create a helper for this or is it possible to write the attribute string

回答1:

You use the bind-attr-helper for this. bindAttr will also work but is deprecated since 1.0 RC8 as pointed out by intuitivepixel.

<img {{bind-attr src=profile.avatar}}/>

More info is available in their guide.



回答2:

For Ember newcomers (whom came to this question by Googleling for example), since Ember 1.11 and later, you should write:

<img src="{{profile.avatar}}"/>

Just as OP wrote in his question!


Note: Since Ember 1.13 the bind-attr helper has been deprecated.