Ember / Handlebars: How to write the attribute string

不羁岁月 提交于 2019-12-11 19:32:56

问题


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.



来源:https://stackoverflow.com/questions/18935225/ember-handlebars-how-to-write-the-attribute-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!