为什么计算属性student.successfulEvaluations不会更新,除非刷新页面?
http://emberjs.jsbin.com/keduco/edit?html,js,output
App.Student = DS.Model.extend({
username: DS.attr('string'),
evaluations: DS.hasMany('evaluation'),
successfulEvaluations: Ember.computed.filter('evaluations.@each.grade', function(evaluation, index, array){
return evaluation.get('grade') >= 10;
})
});
App.Evaluation = DS.Model.extend({
subject: DS.attr('string'),
grade: DS.attr('number'),
student: DS.belongsTo('student')
});
Ember:2.2.0
Ember数据:2.2.1
答案 0 :(得分:2)
EmberJS 2.1 / 2.2中似乎存在关于@each computed properties的错误。可以使用content.@each
而不仅仅是@each
的解决方法(详情请参阅问题)
successfulEvaluations: Ember.computed.filter('evaluations.content.@each.grade', function(evaluation, index, array){
return evaluation.get('grade') >= 10;
})