Making an Async post request inside .forEach is causing me a lot of problems. With or without the use of $resource I will get data lose. Or maybe the server just can't get all the requests processed at the same time, I don't really know.
Here is the code i'm using:
// WHEN THE PROBLEM STARTS
angular.forEach($scope.item, function(item, i){
var thisItemInv = {
"title": $scope.item[i].title,
"host_id": status.id;
};
// POST REQUEST
$Http..
or the same result with
$resource
});
I can get just one result right, and the rest is incomplete. I get around this using jquery ajax with async to false, but I would like to avoid jquery and fix this the angular way