angularjs - Strange behaviour with for loop in Javascript -


i using loop display items, don't know what's wrong going on.

if array length 3 loop repeating 9 times.
if 2 repeating 4 times.

i don't know what's happening.

where going wrong?

for(var i=0; i<list.length; i++){   getorg(list[i]).fetch({}).$promise.then(function (value) {     $scope.displayitem = value.data[0];     console.clear();     console.info($scope.displayitem);     var data = {       'id' : $scope.displayitem.id,       'item':$scope.displayitem.displayconfig[0].propertyvalue     };     $scope.displayitems.push(data);     $scope.displayitems = $scope.displayitem.displayconfig[0].propertyvalue;     console.info($scope.displayitems);   }); } 


Comments