I have the following structure Javacript es5-es6 and the controller class loses the reference in the class Get, I was already investigating but I can not find how to avoid losing the reference.
class Controller {
constructor() {
this.name = 'Test';
}
test() {
console.log(1, this.name);
}
}
referenceController = new Controller();
// working reference: console.log(1, 'Test');
referenceController.test();
class Get {
method() {
return {
controller: referenceController.test
}
}
}
// Lost self reference: console.log(1, undefined)
new Get().method().controller()