I have this code below in my angular app : 

fetchAllRiders(){

this.http.get( this.API + '/driver/all').map( res => res.json())
.subscribe( data => data.map( rider =>{
var distances = [];
this.geocoder.geocode({location: {lat: rider.driver_lat, lng: rider.
driver_lng}}, async function(results, status){

if( status == google.maps.GeocoderStatus.OK){
//then find distance matrix of each rider 
this.distanceMatrixService.getDistanceMatrix({
origins: [this.from],
destinations: [results[0].formatted_address],
travelMode: google.maps.TravelMode.DRIVING
}, async function(response, status ){
if( status == google.maps.GeocoderStatus.OK){
await distances.push(response.rows[0].elements[0].distance.text );
}
} )
console.log( distances );
}
})
} )
//looping ends 
);
}

but i keep getting errors : 
this.distanceMatrixService is undefined meanwhile its defined in my 
constructor. 
please what am i doing wrong. thanks 

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to