我正在使用以下代码来获取其属性已更改的对象的详细信息。
getChangedObject:function(){
console.log('changed name is' , can i get the object here );
}.observes('model.@each.rollNo')
提前致谢。
答案 0 :(得分:0)
在观察者内部,您无法获得导致观察者触发的确切对象,但您可以尝试以下方法,例如迭代模型数组并单独监视更改的属性。
getChangedObject: function() {
let model = this.get('model');
model.forEach(function(item, index) {
var changedAttributes = item.changedAttributes();
item.eachAttribute(function(item, meta) {
var temp = changedAttributes[item];
if(temp){
console.log(' old value ',temp[0],' new value ',temp[1]);
}
});
})
}.observes('model.@each.rollNo')