The title says it all : here is my code.
export class MapComponent {
@ViewChild(DirectionsMapDirective) vc:DirectionsMapDirective;
directionLst : any;
constructor() {
this.directionLst = [];
}
mapClicked = function($event: MouseEvent) {
[...] //hidden code not important
this.vc.updateDirections().then(function(data) {
this.directionLst = data;
});
}
Now if you look at the code inside "mapClicked" there I receive a promise after calling "updateDirections()" the data received is A1. The problem is that in the then function "this" points to null and if I only use "directionLst = data", I get direct is undefined. How can I access the variable from this function? Btw this is typescript of course.