如何将HTML5属性添加到Ember视图

时间:2013-04-12 20:42:59

标签: html ember.js

考虑我有以下HTML代码段:

<div class="content" data-section-content></div>

我希望用这样的Ember视图替换它:

App.ContentView = Ember.View.extend({
   tagName :"div",
   classNames : ["content"],
   ... ( how can i add the >> data-section-content << to the view )
});

数据部分内容添加到视图的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

似乎就是这样 <div class="content" data-section-content></div>是一样的 作为<div class="content" data-section-content=""></div>

所以我可以通过实施来解决问题:

App.ContentView = Ember.View.extend({
   tagName :"div",
   classNames : ["content"],
   attributeBindings : ["data-section-content"],
   "data-section-content": ""
});

或更短

App.ContentView = Ember.View.extend({
   tagName :"div data-section-content",
   classNames : ["content"]
});