I have a list named $scope.propname which has an object named latlong so i need to find the distance of all properties from a specific location so here is what i am doing
for (var i = 0; i < $scope.propname.length; i++) {
if ($scope.propname[i].latlong == "") {
var pptlatlong = ("" + "," + "");
} else {
var pptlatlong = $scope.propname[i].latlong.replace(/\s*,\s*/g, ",");
}
var latlongdata = {
scoord: $scope.loclatlong,
ecoord: pptlatlong
}
$http({
method: 'post',
data: latlongdata,
url: $rootScope.ServiceBaseUri + 'Map/geolocation'
}).then(function successCallback(resp) {
$scope.latlongdist = resp.data;
}, function errorCallback(resp) {});
$scope.propname[i].dist = $scope.latlongdist;
}
So all the object named dist in the list are of same value after the entire loop ends.It should be different for all properties i think before the http response the loop continues is there way to wait till the http of each loop ends and then proceed ?