我有两个对我的web服务的调用,他们都会在同一页面中填充两个不同的网格部分。我如何等待Angular JS直到我的web服务返回
而且我不想在Web服务调用返回之前显示页面。
这里是什么样子:
在ABCCtrl.js............
if (params) {
//I set the please wait dialog on
$scope.pleaseWait = { "display": "block" };
//I hit the first service call and it will populate myFirstUIGrid
TransactionApiServices.getApiUnmergeProcessDetails(params).then(function (results) {
$scope.gridOptions_PR.data = "";
$scope.gridOptions_PR.data.length = 0;
$scope.gridOptions_PR.data = results.data;
console.log(results);
});
//I hit the second service call and it will populate mySecondUIGrid
TransactionApiServices.getApiUnmergeRequestDetails(params).then(function (results) {
$scope.gridOptions_RQ.data = "";
$scope.gridOptions_RQ.data.length = 0;
$scope.gridOptions_RQ.data = results.data;
console.log(results);
});
两个网格填充后,我只希望set the please wait off
和显示器网格。
$scope.toggleDetails = { "display": "block" };
$scope.toggleHeader = { "display": "block" };
$scope.pleaseWait = { "display": "none" };
这里是一个拥有两个UI格的页面:
<div class="home-grid-content" ng-controller="TransactionDetailsUnmergeController">
<div ng-style="pleaseWait">
<div class="refresh" style="width:100%;height:100px;">
<h4>Please wait....</h4>
</div>
</div>
<div ng-style="toggleDetails">
<h3>Unmerge Request Log</h3>
<div ui-grid="gridOptions_RQ" ui-grid-selection class="" ui-grid-pagination ui-grid-auto-resize>
<div class="watermark" ng-show="!gridOptions.data.length">No data available</div>
</div>
<div class="grid-pager">
<uib-pagination boundary-links="true" total-items="totalItems" items-per-page="4" ng-change="pageChanged(currentPage)" ng-show="(totalItems>4) == true"
ng-model="currentPage" class="pagination" direction-links="false" id="HconstUnmerge_1"
first-text="«" last-text="»">
</uib-pagination>
</div>
<br/>
<h3>Unmerge Process Log</h3>
<div ui-grid="gridOptions_PR" ui-grid-selection class="" ui-grid-pagination ui-grid-auto-resize>
<div class="watermark" ng-show="!gridOptions.data.length">No data available</div>
</div>
<div class="grid-pager">
<uib-pagination boundary-links="true" total-items="totalItems" items-per-page="4" ng-change="pageChanged(currentPage)" ng-show="(totalItems>4) == true"
ng-model="currentPage" class="pagination" direction-links="false" id="HconstUnmerge_1"
first-text="«" last-text="»">
</uib-pagination>
</div>
<div style="margin-top:8px;">
<button type="button" class="btn btn-default pull-left" ng-click="backToDetailsPage()">Cancel</button>
</div>
</div>
</div>
使用延迟从底层Q –