I want to do the following, i have a controller like this:
dashboardService.getDashboardStateLakes().then(function (result) {
if (result) {
dosomething();
}, function (err) {
//TODO: handle error;
//alert(err);
throw new Error(err);
});
// populate dashboard lakes status (left upper of the screen)
dashboardService.getDashboardLakesStatus().then(function (result) {
if (result) {
dosomething();
}
}, function (err) {
//alert(err);
//throw new Error(err);
});
and in the service it's doing like this:
this.getDashboardLakesStatus = function () {
var deffered = $q.defer();
$http.get(api.GET_dashboardLakesStatus)
.success(function (result) {
//logic
deffered.resolve(result);
})
.error(function (data, status) {
//logic
deffered.reject(status);
return deffered.promise;
};
Now all i want is to do something when both the ajax calls are finished, but the problem is, sometimes, a 401 is coming back (deliberately) and $q all stops when an error occurs...what is my other option?