I have an angular question.
I am using googles geocode (which is async).
I have a variable 'this.list' that is populated when I enter my function. Then I call geocoder.geocode(...) which is an async function.
However, my already defined variable is undefined inside.
here is a snippet:
alert('entering map init: the list has ' + this.list?.length??0); //verified it is populated
var geocoder = new google.maps.Geocoder();
var coords = new google.maps.LatLng(0, 0);
geocoder.geocode({ 'address': centeringAddress }, function (results, status)
{ alert(this.list); //it now is undefined
... nonrelevent code...}
When I enter the function... I see my 'this.list' has 6 items. I call geocoder.geocode, and then this.list is undefined.
I understand since it is async things set within would not be set outside since it is async; however, why is an already defined variable undefined within the geocode call?
Any suggestions on how to get my 'this.list' item populated within the geocode call?
Thanks Chris