I am struggling with accessing an object: in controller I have an array of functions, function1 receives an object, how can I access this object from this controller of current template?
Scope of "this" inside function1 is functionsArray, and, consequently, it has only function1 and function2 methods, so it is not possible to set a controller variable like this in function1: this.set('data', data_to_pass); - it says "this.set is not a function".
I receive data_to_pass from another component, so one solution is to pass this controller to the component and then pass it back in function1, but that would be a bad decision from performance point of view.
export default Ember.Controller.extend({
t: [], // not visible inside functionsArray
functionsArray: {
function1(data_to_pass) {
// how would I pass data_to_pass to this controller or template here?
this.set('data', data_to_pass); // doesn't work, scope of "this" is functionsArray
console.log('data' + data_to_pass.fullName);
},
function2() {
},
}
});
Aucun commentaire:
Enregistrer un commentaire