How to store a json formatted value in a loop
漂亮男人
漂亮男人 2017-05-16 13:22:13
0
3
449

Now we are calling a method repeatedly, in the method
function getSecondInfo(ID) {
$http({

url: "http://192.168.199.239:8013/Productions/GetProductionsByID?ProductionID=" + ID,
 method: 'get'
   }).success(function(data) {
            $scope.json[ID] = data[0];
        });
        $scope.ManJsonArr.push($scope.json);
    }
    
    上述方法是在一个循环中调用,id值是循环中的i值  我每次循环都会为json赋值,最后执行完上述循环,json的值是最后一次执行的还是结果,还是所有的执行的结果
漂亮男人
漂亮男人

reply all(3)
巴扎黑

is all all

曾经蜡笔没有小新

This is equivalent to calling the function ajax request to pass in the url parameters every time you loop, then $scope.ManJsonArr stores the values ​​of all your push

我想大声告诉你

$scope.json contains all the values ​​obtained by ajax

However, $scope.ManJsonArr will have n (n is the number of loops) identical $scope.json objects

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template