Than I would not use a for loop. Make your first request. Wait for the 
result with the next ID (if I understood you right), after that just make 
the next call to get the next id (recursive programming). Or watch a nextId 
variable, set that and execute the next call in the watch callback function 
(when the nextId changes).

But if you have a chance to change the backend I would try to make a batch 
operation (addCompletedConditions), give all the data you have and make the 
whole loop thing on the backend. 1 request that hast hundrets of ms that 
triggers the next and so on will not be the most performant way.

Am Dienstag, 4. August 2015 09:20:46 UTC+2 schrieb Piotr L:
>
> Thanks but What can i do if i need this variable to next iteration. 
> Something like this:
>  
> $scope.nextId = "a";
> $scope.addTask = function() {
>             for (i in $scope.completeConditions) {
>                 conditionFactory.addCompleteConditions($scope.
> completeConditions[i], data.toJSON().objectId, $scope.nextId).then(
> function(data) {
>                     $scope.nextId = data.toJSON().objectId;
>                 })
>             };
>     };
>
> in addCompleteConditions function argument $scope.nextId always is "a". 
> How make to change it between iterations? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to