In my code, I have a function where I need to assign a specific value returned from an HTTP service to a member variable.
calculateDistance() {
for (var ix=0; ix<this.rps.length; ix++) {
this.googleService._distanceBetween(this.myLatLng, this.rps[ix].latLng)
.subscribe(response => {
this.resp = <GeoResponse>response;
this.rps[ix].distFromMe = this.resp.distance.toString();
});
}
}
The issue I'm facing is that I can't access the array named rps within the observable.
Is there a different way to solve this problem?