我可以监控属性hasDirtyAttributes以了解是否有任何属性是脏的。
如何监控特定属性是否脏?
类似的东西:
attributeOneNeedSave: Ember.computed('attributeOne', function() {
return this.get('dirtyAttributes.attributeOne');
})
答案 0 :(得分:4)
您可以使用changedAttributes方法来发现属性是否已更改。要将其转换为计算属性,只需在该属性更改时调用它。
AlertDialog
此外,如果Ember Data将属性更改为原始值,我不能100%确定Ember Data是否会从isNameDirty: Ember.computed('name', function() {
const changedAttributes = this.changedAttributes();
return !!changedAttributes.name;
})
删除该属性。所以可能可以得到这样的东西:
changedAttributes
如果是这种情况,也要检查是否相等。
const changedAttributes = {
name: ['Bob', 'Bob']
};