I am working with a component in angular, declared a variable to hold an image, so, later will render the image in canvas context.
So, I has in the component, declared a function named Draw_Map();, it expect the "this" context to be the component.
but, when I try to call the function from inside an .onload event, like in the follow code, it is unable to find the function, obvious the context is wrong from inside an event. But, I don't know how to fix it.
so my code is:
mapground = new Image();
...
this.mapground.src = this.URLBackGroundPicture;
this.mapground.onload = function() { this.Draw_Map(); } // it fails.
....
this.Draw_Map(); // it works.
Error: Angular throw the error "Property 'Draw_Map' does not exist on type 'GlobalEventHandlers'.ts(2339)"
how to solve this problem?.