suchen

Heim  >  Fragen und Antworten  >  Hauptteil

So speichern Sie einen JSON-Formatwert in einer Schleife

Jetzt rufen wir eine Methode wiederholt auf. In der Methode
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的值是最后一次执行的还是结果,还是所有的执行的结果
漂亮男人漂亮男人2822 Tage vor450

Antworte allen(3)Ich werde antworten

  • 巴扎黑

    巴扎黑2017-05-16 13:24:13

    是所有的 所有的

    Antwort
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:24:13

    你这相当于每次循环就调用一次函数ajax请求传入url参数,那么$scope.ManJsonArr里存的就是你所有push的值

    Antwort
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:24:13

    $scope.json里是你所有ajax获取的值

    然而$scope.ManJsonArr会有n个(n是循环的次数)相同的$scope.json对象

    Antwort
    0
  • StornierenAntwort