问题
It explains here how to observe items in an array with ember. My question is how can I determine the item being added/removed with this method?
回答1:
You can use the addArrayObserver method to find items added/removed from an array.
The code will look something like this
that.get('content').addArrayObserver(this, {
willChange: Ember.K,
didChange: function(array, start, removeCount, addCount) {
alert(array[start]);
}
});
More information can be found here.
Here is a link to a working demo.
来源:https://stackoverflow.com/questions/30011028/how-to-determine-item-being-added-removed-to-an-observed-array-in-ember