问题描述
我基本上有一个功能标志,它被添加到用户保存配置的列表中。保存时,我在服务对象上创建了一个计算属性,如下所示。
//classify() just removes the '_' and Makes it title case 'add_location' --> 'AddLocation'
defineFeature(feature) {
defineProperty(this,`is${classify(feature)}`,computed('session.account.features.[]',function() {
return this.hasFeature(feature);
}));
},
现在这在服务对象上设置属性,我在我的 .hbs 文件中使用它。但是它不会反映,除非我触发 <serviceObj>.notifyPropertyChange('is<FlagName');
我很困惑为什么 Ember 不会自行更新,或者我做错了什么?
添加更多上下文
我的处理程序文件
{{#if featureService.isAddLocation}}
<span>User can now add locations for this account</span>
{{/if}}
组件文件
一个基本上切换标志的保存功能。
onSave() {
// This method is called on user action
let account = get(this,'account');
account.enableSaveLocation().then(() => {
account.reload().then(() => {
// basically only after the save the feature 'add_location' gets added to
// the features array in the 'account' model
featureService.defineFeature('add_location');
//featureService.notifyPropertyChange('isAddLocation'); // Without this line the template doesnt reflect the change
})
})
}
Ember: v3.4
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)