如何在其模板中使用 View 属性?

How can View properties be used in its template?

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>

我想根据视图'opened'的值更改图标(plus/minus)。

绑定属性不起作用。我该如何处理?

您需要在模板中使用 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>