Debugging Async calls
var maxRetry = 3;
$scope.retries = 0;
$scope.execute = function() {
$scope.retries = 0;
$scope.status = 'fa-spinner fa-spin';
makeAjaxCall();
}
function successAjaxCall(response) {
$scope.result = response.data;
$scope.status = 'fa-thumbs-o-up';
}
function errorAjaxCall(err) {
if (maxRetry > $scope.retries) {
setTimeout(makeAjaxCall, 2000);
} else {
$scope.status = 'fa-exclamation-triangle';
}
}
function makeAjaxCall() {
$scope.retries++;
$http.jsonp('nonworkingApiUrl')
.then(successAjaxCall, errorAjaxCall);
}