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
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
Share Improve this question edited Dec 24, 2016 at 14:00 Marcio Junior 19.1k4 gold badges46 silver badges47 bronze badges asked Jul 31, 2013 at 16:52 seagodseagod 1171 gold badge1 silver badge4 bronze badges 1- 1 What is inside self.resultList? I think the array contains both plain JS Objects and Ember Objects. – mavilein Commented Jul 31, 2013 at 17:16
2 Answers
Reset to default 21You 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);
}
})