是否可以使用车把表达式来设置 div 的 ID?



我正在尝试为我的ZingChart重用模板。模板非常简单

<h4>{{title}}</h4>
<div id={{templateId}} class="zingChart"></div>

不幸的是,它看起来像ZingChart框架要求div有一个id附加到它,所以我试图通过一个类似于设置{{title}}的handlebars表达式来设置它在我的ZingChartdiv上面的行。我不能设置id的东西,因为只有一个图表将显示。

这可能吗?

谢谢

要在车把中设置这样的属性,需要使用bind-attr,如下所示:

<div {{bind-attr id=templateId}} class="zingChart"></div>

关于这方面的更多阅读可以在这里找到:http://guides.emberjs.com/v1.10.0/templates/binding-element-attributes/

最新更新