javascript - Requesting data from REST endpoint in loop, works in FF not in chrome -
javascript - Requesting data from REST endpoint in loop, works in FF not in chrome -
i'm trying loop through array of users , image external rest endpoint each user in loop , set user.
this works great in firefox, in chrome gets 1 image , sets users.
the weird thing $http request get's called right number of times in chrome.
any ideas what's going on here?
// loop through users for(var = 0; < $scope.users.length; i++) { get_image(i); } // fetches random image , adds user function get_image(index) { console.log('index = '+index); // todo: something's screwy this. in ff loads new image per user, in chrome loads same image user $http.get('http://uifaces.com/api/v1/random').then(function(response) { console.log('in get'); // <-- line get's called many times there users in array. $scope.users[index].face = response.data.image_urls.normal; }); }
i think race condition. i'm not sure, why works way, have implemented getting gravatars method - https://github.com/caolan/async#each, there async version browser use.
javascript angularjs google-chrome firefox
Comments
Post a Comment