self.resultList.forEach(function(item, index, enumerable){
console.log(self.resultList);
item.id=11;
item.get('id');
});
the item like this:
if item.id = 11;
the exception like this:
Assertion failed: You must use Ember.set() to access this property (of [object Object])
so item.get('id') or item.set('id',11)
the exception like this
Uncaught TypeError: Object # has no method 'get'
is this item not the Ember's Object?so what the item is?
could someone tell me how to change the 'itme.id's value..
Thanks a million
You can use the Ember.set(yourObject, propertyName, value);
and Ember.get(yourObject, propertyName);
to safely set and get properties.
In your case:
self.resultList.forEach(function(item, index, enumerable) {
Ember.set(item, "id", 11);
Ember.get(item, "id");
});
In my case I did it in this way
//In my controller I've defined the array displayInfoCheckboxes: [ { turnover: { label: "Turnover", value: 1, propertyName: "turnover" } }, { pl: { label: "P&L", value: 1 } } ] //and in my handler I passed the full string path to the property in the set method let displayInfoCheckboxes = this.get('displayInfoCheckboxes'); let controller = this; displayInfoCheckboxes.forEach(function(items,index) { for (var key in items) { controller.set('displayInfoCheckboxes.' + index + '.' + key + '.value', false); } })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.