I have two javscript async $http funtions: which I am using with angular js in a nested way to create a table dynamically.
I want some way to execute these functions to synchronously.
Right now, j loop executes only on the initial value of resultB. Once the table is compiled then the fuctB gets executed for all values of i.
$scope.funcA = function() {
$http({
method : 'GET',
url : url,
}).then(function successCallback(response) {
$scope.resultA = response.data;
//process based on $scope.resultA
for (var i = 0; i < $scope.resultA .length; i++){
$scope.funcB($scope.resultA[i][0]);
for(j=0; j<$scope.resultB .length; j++){
//process based on $scope.resultB
}
}
$compile(/* document element*/);
}, function errorCallback(response) {
console.log(response.statusText);
});
}
$scope.funcB = function(k){
$http({
method : 'GET',
url : url+k
data: k ,
}).then(function successCallback(response) {
return $scope.resultB = response.data;
}, function errorCallback(response) {
console.log(response.statusText);
});
}