I'm trying to set the attribute 'show' of an object, that comes from an array which is served by a service.
the service (not the problem):
// services/events.js
export default Ember.Service.extend({
types: [
{"code": 0, "label": 'Performance', "show": true, "css": 'warning'},
{"code": 1, "label": 'Preview', "show": true, "css": 'danger'},
....
],
});
in my controller I have an action that should update the attribute 'show':
// controller
const { service } = Ember.inject;
export default Ember.Controller.extend({
eventsService: service('events'),
....
actions: {
setEventFilter: function(code) {
....
let obj = this.get('eventsService.types').objectAt(code);
// I get a proper Object here, that also has a set-function:
console.log(obj);
// this fails with 'Uncaught TypeError: obj.set is not a function':
obj.set('show', false);
}
}
});
I've read the answers here Ember: set array value for specific key , tried all the possibilities, nothing worked in my case.
What I don't understand is, that I can see the function 'set' in console, yet I still get that error:
Any suggestions? Anybody got an idea what I'm doing wrong?
Aucun commentaire:
Enregistrer un commentaire