App.FolderListItemView = Ember.View.extend({
templateName: 'folder-list-item',
tagName: 'li',
classNames: ['folder'],
classNameBindings: ['opened'],
opened: false,
click: function (e) {
this.set('opened', !this.get('opened'));
}
});
<script type="text/x-handlebars" data-template-name="folder-list-item">
<i {{bind-attr class="opened:icon-content-plus:icon-content-minus"}}></i>
...
</script>
我想根据视图的“已打开”值更改图标(加号/减号)。
bind-attr不起作用。我该怎么处理这个?
答案 0 :(得分:1)
您需要在模板中使用view.opened
属性
<script type="text/x-handlebars" data-template-name="folder-list-item">
<i {{bind-attr class="view.opened:icon-content-plus:icon-content-minus"}}></i>
...
</script>