emberjs绑定数据属性 [英] emberjs bind data attributes
本文介绍了emberjs绑定数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道在调用视图时是否有方法绑定模板中的数据属性。
例如(这不起作用):
{view App.SomeView data-dateBinding =currentDate}}
我已经结束了方式:
< a {{bindAttr data-date =currentDate}}>< / a>
调用视图时必须有一种方法?
解决方案
您必须在App.SomeView中定义要放入HTML的属性。
App.SomeView = Ember.View.extend({
attributeBindings:[data-date]
....其余的视图
})
现在 data-dateBinding
应该工作: p>
{{查看App.SomeView data-dateBinding =currentDate}}
pre>
I am wondering if there is a way to bind data attributes in a template when calling a view.
For example (this doesn't work):
{{ view App.SomeView data-dateBinding="currentDate" }}
I have ended up doing it this way:
<a {{bindAttr data-date="currentDate"}}></a>
There must be a way to do it when calling the view?
解决方案You have to define in App.SomeView which attributes you want put in the HTML.
App.SomeView = Ember.View.extend({ attributeBindings: ["data-date"] .... rest of view })
Now
data-dateBinding
should work:{{view App.SomeView data-dateBinding="currentDate" }}
这篇关于emberjs绑定数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文