考虑我有以下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 )
});
将数据部分内容添加到视图的最佳方法是什么?
答案 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"]
});