1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>angularjs-分页</title> <link rel="stylesheet" href="../../plugins/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="../../plugins/angularjs/pagination.css"> <script src="../../plugins/jQuery/jquery-2.2.3.min.js"></script> <script src="../../plugins/bootstrap/js/bootstrap.min.js"></script> <script src="../../plugins/angularjs/angular.min.js"></script> <script src="../../plugins/angularjs/pagination.js"></script> <script> var testApp = angular.module('test',['pagination']); testApp.controller('testController',function ($scope, $http) { $scope.paginationConf = { currentPage: 1, totalItems: 10, itemsPerPage: 10, perPageOptions: [10, 20, 30, 40, 50], onChange: function () { $scope.reloadList(); } };
$scope.reloadList = function () { $scope.findPage($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage); }
$scope.findPage=function(page,size){ $http.get('./pagination_'+page+'.json').success( function(response){ $scope.list=response.rows; $scope.paginationConf.totalItems=response.total; } ); } }); </script> </head> <body ng-app="test" ng-controller="testController"> <table border="1"> <thead> <tr> <td>主键</td> <td>名称</td> <td>首字符</td> </tr> </thead> <tbody> <tr ng-repeat="entity in list"> <td>{{entity.id}}</td> <td>{{entity.name}}</td> <td>{{entity.firstChar}}</td> </tr> </tbody> </table> <tm-pagination conf="paginationConf"/> </body> </html>
|