var    $scope.units = [1,2];
var  $scope.shiftplans = ['plan1','plan2','plan3']
         for(var i=0;i<$scope.units.length;i++){            
          for(var a=0;a<$scope.shiftplans.length;a++)  {
            console.log('i:'+i);
            console.log('a:'+a);
         } 
        }
prints :
i:0 a:0 i:0 a:1 i:0 a:2 i:1 a:0 i:1 a:1 i:1 a:2
but :
var    $scope.units = [1,2];
    var  $scope.shiftplans = ['plan1','plan2','plan3']
  for(var i=0;i<$scope.units.length;i++){            
     for(var a=0;a<$scope.shiftplans.length;a++)  {
       ***$http.get(function(){
               console.log('i:'+i);
               console.log('a:'+a);
       });***
     } 
 }
Console log in above ajax prints values in different values based on ajax response.
how to handle AJAX to complete and later to move to looping ?

