【发布时间】:2018-03-13 11:44:19
【问题描述】:
我有一个关于多个像这样嵌套的 http 请求的问题:
$http({
method: 'jsonp',
url: 'URL1',
}).then(function (response) {
// Response result 1
// nested http request --> after first http success
$http({
method: 'jsonp',
url: 'URL2'
}).then(function (response) {
// Response result 2
}, function Error(response) {
$scope.users = response.statusText;
}).finally(function () {
$scope.loading = false;
});
});
};
有没有办法同时在视图上显示两个结果?当我添加$scope.data.length 以确定显示按钮if length is > 1 时,该按钮位于任何数据之前。我想同时显示两个成功的数据。这可能吗?
我已经阅读了有关 $q 的信息,但这是否可以在这里工作并在两个结果数据可用的同时渲染视图?
PS:我知道在控制器中添加http 请求是不好的做法,但这只是为了测试。
【问题讨论】:
标签: javascript angularjs http model-view-controller