小编Hes*_*ama的帖子

函数中的$ http.get方法

我有一个函数和几个$ http获取请求.我需要在执行每个$ http请求后调用另一个函数.但它总是在请求完成之前执行该功能.是什么原因?有办法解决吗?

$scope.json=function(){
        $scope.loading = true;
        $http.get(DataElementUrl).then(function (response) {
            if (!response.data == "")
            dataElementJson = response.data;

        });
        $http.get(categoryComboUrl).then(function (response) {
                if (!response.data == "")
                    categoryComboJson = response.data;                   
        });
        $http.get(categoryUrl).then(function (response) {
                    if (!response.data == "")
                       categoryJson = response.data;                        
        });
        check++;
        $scope.getJson();
};
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

2
推荐指数
1
解决办法
167
查看次数

标签 统计

angularjs ×1

javascript ×1