我试图在角/引导站点上实现分页.我的数据显示正确的每页行数,我有角度分页显示正确的页数…但是如果我能找到任何地方告诉我如何使用分页来刷新我的数据当一个页面#被点击了…? {{currentPage}}正在更新,但不知道如何让它调用getPresentations来更新列表.
<div> {{noOfPages}} {{currentPage}} {{maxSize}} <pagination num-pages="noOfPages" current-page="currentPage"></pagination> </div> <script type="text/javascript"> angular.module('app',['ui','shared','ui.bootstrap']).controller('AppCtl',function ($scope,$http,$window) { var mvc = $window.MVC; $scope.noOfPages = 0; $scope.currentPage = 1; $scope.maxSize = 5; $scope.getPresentations = function () { $http.get(mvc.base + "API/Presentations?page=" + $scope.currentPage + "&itemsPerPage=10") .success(function (result) { $scope.presentations = result.Items; $scope.noOfPages = result.TotalPages; $scope.currentPage = result.Page; }) .error(function (result,status) { $scope.newModal.errors = mvc.getApiErrors(status,result); }); }; $scope.getPresentations(); }); </script>
你有两个选择:
原文链接:/angularjs/142980.html这是与$手表相关的页面
$scope.$watch('currentPage',function(newPage){ $scope.watchPage = newPage; //or any other code here });
这里有一个使用回调:
$scope.pageChanged = function(page) { $scope.callbackPage = page; $scope.watchPage = newPage; };
使用像:
<pagination on-select-page="pageChanged(page)" num-pages="noOfPages" current-page="currentPage"></pagination>
最后,工作的朋友显示了两种方法:
http://plnkr.co/edit/UgOQo7?p=preview