I'm dealing with a code snippet that looks like this:
myMethod(data: any, layerId: string, dataSubstrings): void {
someObject.on('click', function(e) {
this.api.getSomething(a).subscribe((result: any) => { // ERROR CALL 1. It is from another component
// code
this.outSideMethod(a)); // ERROR CALL 2
}
}, (error: any) => {
return {};
})
});
outSideMethod(a): any[] {
//etc
}
I am encountering an issue while trying to call this.api.getSomething(a));
(as well as outSideMethod()) and receiving the error message 'Cannot read property 'getSomething' of undefined.'
I seem to be struggling with using 'this' in the context of object-oriented programming (OOP), can someone kindly provide me with some insights?