I'm using for loop to send ajax requests to delete multiple items in datatables. Is there any way I can call functions after all the requests are succeeded? Calling functions after every request bring some issues for my datatables, also it's not working if calling functions outside of loop cause they're asynchronous requests
for(var i = 0; i < $scope.selectedRows.length; i++) {
$http({
method: 'DELETE',
url: $scope.url + '/' + $scope.selectedRows[i].name + '?recursive=true'
})
.then(function(res) {
// $scope.clearSelect();
// $scope.dtInstance.rerender();
// $mdDialog.hide();
}, function(res) {
console.log('error');
})
}
idssomething likeDELETE /post?ids=1,3,5,7,8...etc. this way can delete in one request$q.all[<promise1>,<promise2> ..]method. It will finish when ALL aync call will finish