在我的 component.js 中,我正在观察下面的组件属性..
valueObserver : function(){
console.log('which item changed??')
}.observes('list.@each.isChecked'),
如何找出哪个 Item isChecked 已更改?
完整的组件代码如下
Ember.Component.extend({
user: undefined,
list: undefined,
init: function() {
this._super();
},
visibilityChanged: function() {
if(this.get('isVisible')) {
var _this = this;
var account = this.get('accountService').get('account');
this.get('user').getLists(account.get('uid'))
.then(function(response) {
var items = response.map(function(item) {
item.isChecked = false
return item;
});
_this.set('list', items);
});
}
}.on('init').observes('isVisible'),
valueObserver : function(){
this.get('list').forEach(function(item) {
if (item.get('isDirty')) {
// Item has changed
}
});
}.observes('list.@each.isChecked')
});