Here is my code
for (var i=0; i<5; i++) {
    var url = generate_url(i) ;
    $http.get(url).then(function(response){
        var param2 = response.data.param2
        $scope.outputData.push({'index':i, 'param':param2}) ;
    }) ;
}
In this example, I suppose to obtain an array in the $scope.outputData with data similar to this:
[
  {'index':0,param:'a'},
  {'index':1,param:'b'},
  {'index':2,param:'c'},
  {'index':3,param:'d'},
  {'index':4,param:'e'},
]
but what i get is data like this:
[
  {'index':4,param:'a'},
  {'index':4,param:'b'},
  {'index':4,param:'c'},
  {'index':4,param:'d'},
  {'index':4,param:'e'},
]
In this case, the externel data that I mean is the variable i, 
Please could you tell me the trouble ? and how do I proceed to attend my goal? Thank you in advance and sorry for my english :)
 
     
     
    