Ember.js Ember computed属性返回一个筛选器
我的控制器上有一个简单的属性。它用于呈现对话中所有电子邮件的列表Ember.js Ember computed属性返回一个筛选器,ember.js,ember-data,Ember.js,Ember Data,我的控制器上有一个简单的属性。它用于呈现对话中所有电子邮件的列表 conversation: (-> App.Email.filter (otherEmail) => @get('model').isIncludedInConversation otherEmail ).property('model') 当我转到页面时,一切都很顺利,因为CP还没有计算出来。当我发送新电子邮件时,对话属性不会更新。我需要切换我正在查看的电子邮件以触发对话重新计算 我知道过滤器正在更新
conversation: (->
App.Email.filter (otherEmail) =>
@get('model').isIncludedInConversation otherEmail
).property('model')
当我转到页面时,一切都很顺利,因为CP还没有计算出来。当我发送新电子邮件时,对话
属性不会更新。我需要切换我正在查看的电子邮件以触发对话
重新计算
我知道过滤器正在更新。问题是CP的值没有改变,并且基础的{{{each conversation}}
没有更新。我怎样才能做到这一点
编辑:我在这里添加了小提琴:我不熟悉coffeescript,因此我假设您的代码相当于:
conversation: function() {
var self = this;
App.Email.filter( function( otherEmail ) {
return self.get('model').isIncludedInConversation( otherEmail );
});
)}.property('model')
我很想说,您应该在filter函数之外捕获model
conversation: (->
_model = @get('model')
App.Email.filter (otherEmail) =>
_model.isIncludedInConversation otherEmail
).property('model')
此代码适用于我最新版本的余烬和余烬数据。其他电子邮件来自哪里?它不应该是属性依赖项吗?@MilkyWayJoe它通过
filter
函数传递给用于筛选的回调函数