Restangular post in loop


I need to call a list of inside of a loop, to add many user (for example)

I have a factory that do something like that:

createUser (user) {
return Restangular.all(URL).post(user);

then in controller In need to call this factory inside of a loop:

for( var us in users){

the problem is that I cant do this! it add always only the last user object!, so how to do $q.all() using Restangular, or there are any other solution??


var promises = [];
for (var us in users) {
$q.all(promises).then(function (responses) {
// responses is an array with one return value per request made

Answered By – ATEF CHAREF

Answer Checked By – Gilberto Lyons (AngularFixing Admin)

Leave a Reply

Your email address will not be published.