Here's a unique array of account id and I want to call Ajax to retrieve the relevant accounts.
var account_id_unique = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"];
I decided to use a for loop and call AJAX inside the loop. However, instead of retrieving and storing different values to $scope.account = data;
, I'm only storing the last value that I ran through the for loop. I tried to move $scope.account = data;
to outside of the loop, but it's not possibly since I'm making Ajax call inside the loop. Is there a better way?
for (i=0; i<account_id_unique.length; i++){
$http.get('api/accounts/'+ account_id_unique[i].toString())
.success(function(data, status, headers, config){
console.log(data);
$scope.account = data;
}).error(function(data, status, headers, config){
console.warn(data);
});
};
Additional: This is a snippet of html file. I'm trying to print out a list of accounts and artifacts to the front page.
SNS:{{ account.vendorCode }} identity id: {{account.identity.identityId}}