我正在尝试为基于data属性的组件设置类名。我成功地将数据设置为template.hbs,我看到该组件已呈现。但是在component.js中,我无法设置类名
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['complete:completed'],
complete: Ember.computed('isCompleted', function(){
return this.get('isCompleted');
})
});
这不起作用。班级名称没有计算。我怎样才能做到这一点?
这是我的路线:
export default Ember.Route.extend({
model: function(){
return Ember.RSVP.hash({
todoList: this.store.findAll('todo')
});
}
});
和template.hbs
{{#each todoList as |todo|}}
{{todo-item todo=todo}}
{{/each}}
答案 0 :(得分:1)
export default Ember.Component.extend({
tagName: 'li',
classNameBindings: ['todo.isCompleted:completed']
});