为什么Em.Checkbox上的这个checkedBinding不起作用?
以下是说明问题的代码段:
使用此模板
{{#each person in people}}
<li>{{view Em.Checkbox checkedBinding=person.isSelected}}</li>
{{/each}}
和这个控制器
App.IndexController = Em.Controller.extend({
count: function(){
return this.get('people').filterBy('isSelected').get('length');
}.property('people.@each.isSelected'),
people: Em.A([
Person.create({firstName: 'Kris', lastName: 'Selden', isSelected: true}),
Person.create({firstName: 'Luke', lastName: 'Melia', isSelected: false}),
Person.create({firstName: 'Formerly Alex', lastName: 'Matchneer', isSelected: false})
])
});
我看到所有复选框都未选中
Here是一个小提琴。
答案 0 :(得分:3)
您需要将checkedBinding
包装在引号中,如下所示:
{{#each person in people}}
<li>{{view Em.Checkbox checkedBinding="person.isSelected"}}</li>
{{/each}}