如何知道Angular应用程序可发送的所有HTTP请求?

时间:2016-10-04 13:51:34

标签: angularjs api

是否有可能生成一种文档, 在哪里处理由特定Angular应用程序发送的所有HTTP请求?

1 个答案:

答案 0 :(得分:0)

尝试将url地址存储到数组中,然后循环HTTP请求调用。 这样的事情可能是:

for (var i=0 ; i < $scope.urls.length ; i++)
{
  $http.get($scope.urls[i])
        .success(function(response){
            $scope.results[i] = response.data;
        })
        .error(function(response){
            $scope.errors[i] = response.error;
            $scope.errormessages[i] = response.errormessage;
        });
}

并使用范围。$ evalAsync(function(){})如果需要同步调用。