【发布时间】:2017-04-02 03:49:30
【问题描述】:
我有两个计算属性应该在month 属性更改后触发。但是,其中只有一个会着火,而另一个不会。
classesForMonth 在初始化时触发一次(当month 第一次设置时),之后不再触发。
我认为这可能是由classesForMonth.content 语法引起的,我必须在模板中使用查询 DS 后呈现从 Promise 接收到的对象。
请帮助我走上正轨。
classesForMonth: function() {
console.log('hi im querying store') // doesn't fire on month change
return this.get('store').query('class', {
month: this.get('month') + 1,
});
}.property('month'),
formattedMonth: function(){
console.log('hi im formatting month') // does fire on month change
return moment.months()[this.get('month')]
}.property('month')
【问题讨论】:
-
您使用的是什么版本的 ember?
-
我使用的是 Ember 2.8。
-
您在模板中使用 formattedMonth 吗?
-
是的,我在我的模板中都使用了这两种方法。 formattedMonth 正确呈现和更改。
-
附带说明:您应该改用
Ember.computed('month', function() {...})表示法。是的,我认为你在模板的正确轨道上。您能否确认,返回this.get('store').query成功完成?你注入商店了吗?我假设您的模板中可能有classesForMonth.content之类的东西?这可能不会调用您正在寻找的绑定逻辑
标签: ember.js