When I want to save a variable data, it is saved and displayed in the console, but if I want to use it elsewhere, it tells me that this undefined
and I do not know what to do.
Here is a fragment of that code:
public valoractual:number;
google.maps.event.addListener(marker, 'click', (function(marker,i) {
return function() {
this.valoractual=i;
console.log(this.valoractual);//me la imprime aqui pero ni puedo usarla afuera
infowindow.setContent(locationtemp[i]);
infowindow.open(this.map, marker);
}
})(marker,i));
This only happens to me when I try to do it inside a bookmark and I do not know how to fix it.