I probably miss something really stupid (Ember newbie), but I can’t figure out how to change the array that my Ember Controller is managing except to set up a completely new array.
For instance. I have the following test function in my controller. When the user clicks, I want to change each element of the managed array (or it can be a separate element) with a new value.
I understand that you have to go through the “set” to make the changes known to Ember, so I thought this would work:
clickHandler:function(e){
var temp = this.get("itemList").copy();
for (var i = 0; i < temp.length; i++) {
temp[i].desc = "CANCELLED";
}
this.set('itemList', temp);
}
I make a copy of the array, modify it, and then return. But for some reason Ember complains about the 4th line, where I change the contents of temp [i] .desc, saying that I need to use Ember.Set. I suggested that I could change the “stand-alone” copy and then install it back, but not-go, and I cannot understand why. Other array operations seem to work, such as shift / unshift / pop.
source
share