我使用angularJs已完成,我用這個功能在我的控制器從數據庫我需要調用一個函數時,先前的功能
this.callServer = function callServer(criteria) {
ctrl.searchParameters = criteria;
ctrl.isLoading = true;
var start = $scope.itemsPerPage * ($scope.currentPage - 1);
var limit = $scope.itemsPerPage;
service.getRandomsItems(criteria, start, limit).then(
function(result) {
var remainder = $scope.totalItems % $scope.itemsPerPage
if (remainder > 0)
$scope.numPages = parseInt($scope.totalItems/$scope.itemsPerPage) + 1;
else
$scope.numPages = parseInt($scope.totalItems/$scope.itemsPerPage);
ctrl.displayed = result.randomsItems;
$scope.totalItems = result.total;
ctrl.isLoading = false;
});
};
}
得到的數據和我在我的控制器也調用這個函數來處理分頁問題
$scope.pageChanged = function(currentPage) {
$scope.currentPage = currentPage;
ctrl.callServer($scope.criteria);
}
正如你所看到的,我的功能callServer回報ctrl.displayed這是顯示在當前頁面的行
現在我想用新的一頁工作,所以我叫ctrl.callServer獲得新的頁面,然後我叫ctrl.selectCurrentPage()就是這樣
$scope.pageChanged = function(currentPage) {
$scope.currentPage = currentPage;
ctrl.callServer($scope.criteria);
ctrl.selectCurrentPage() // I want this function to be called when ctrl.callServer($scope.criteria) is finished
}
其中
ctrl.selectCurrentPage = function() {
ctrl.selection.push(this.displayed[i].userId);
ctrl.selectionRow.push(this.displayed[i]);
}
用簡單的英語我想ctrl.selectCurrentPage被調用時ctrl.callServer是finsih,並獲得新的數據 但沒有發生。
它的作品非常感謝:)您非常喜歡..... –
@BelalOthman酷:) –