I'm facing an issue and can't seem to navigate through it. I am setting up a callback from a third party directive, but the callback is not returning with the correct scope. This means that when it reaches my controller, this
refers to some other scope that I can't quite identify, making it unable to access any member variables. How can I switch back to my controller's scope?
<ui-gmap-layer type="HeatmapLayer" onCreated="$ctrl.heatLayerCallback"></ui-gmap-layer>
Component Controller:
heatLayerCallback(heatLayer: google.maps.visualization.HeatmapLayer) {
this.heatMapLayer = heatLayer;
// 'this' here does not reference my controller
}
If I modify the callback like so:
<ui-gmap-layer onCreated="$ctrl.heatLayerCallback(layer)"></ui-gmap-layer>
Then the callback executes within the correct scope (i.e. my controller), but unfortunately, the parameter layer
is lost ;/
Notes
I am using Typescript, Angular 1.6, and Angular Components