我使用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酷:) –