<html>
<head>
<meta charset='utf-8'>
<script src="js/angular.js"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body ng-app="MyApp">
<div ng-controller="PaginationCtrl">
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | offset: currentPage*itemsPerPage | limitTo: itemsPerPage">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td>{{item.description}}</td>
</tr>
</tbody>
<tfoot>
<td colspan="3">
<div class="pagination">
<ul>
<li ng-class="prevPageDisabled()">
<a href ng-click="prevPage()">« Prev</a>
</li>
<li ng-repeat="n in range()" ng-class="{active: n == currentPage}" ng-click="setPage(n)">
<a href="#">{{n+1}}</a>
</li>
<li ng-class="nextPageDisabled()">
<a href ng-click="nextPage()">Next »</a>
</li>
</ul>
</div>
</td>
</tfoot>
</table>
</div>
</body>
</html>
 var app = angular.module("MyApp", []);

 app.filter('offset', function() {
return function(input, start) {
start = parseInt(start, 10);
return input.slice(start);
};
}); app.controller("PaginationCtrl", function($scope) { $scope.itemsPerPage = 5;
$scope.currentPage = 0;
$scope.items = []; for (var i=0; i<; i++) {
$scope.items.push({ id: i, name: "name "+ i, description: "description " + i });
} $scope.range = function() {
var rangeSize = 5;
var ret = [];
var start; start = $scope.currentPage;
if ( start > $scope.pageCount()-rangeSize ) {
start = $scope.pageCount()-rangeSize+1;
} for (var i=start; i<start+rangeSize; i++) {
ret.push(i);
}
return ret;
}; $scope.prevPage = function() {
if ($scope.currentPage > 0) {
$scope.currentPage--;
}
}; $scope.prevPageDisabled = function() {
return $scope.currentPage === 0 ? "disabled" : "";
}; $scope.pageCount = function() {
return Math.ceil($scope.items.length/$scope.itemsPerPage)-1;
}; $scope.nextPage = function() {
if ($scope.currentPage < $scope.pageCount()) {
$scope.currentPage++;
}
}; $scope.nextPageDisabled = function() {
return $scope.currentPage === $scope.pageCount() ? "disabled" : "";
}; $scope.setPage = function(n) {
$scope.currentPage = n;
}; });

最新文章

  1. 【BUG】wego购物分享系统未登陆分享宝贝时查看宝贝自动新增产品数据
  2. Spring AOP:面向切面编程,AspectJ,是基于spring 的xml文件的方法
  3. Hive(四):c#通过odbc访问hive
  4. Part 9 Union and union all in sql server
  5. Scut 进阶:网络模型拓扑
  6. JBoss 系列六十九:CDI 基本概念
  7. OC版贪吃蛇
  8. ThreadLocal 原理解析
  9. 05-移动端开发教程-CSS3兼容处理
  10. Nordic nRF51/nRF52开发环境搭建
  11. 描述逻辑(DL)基础知识
  12. Elasticsearch集群优化
  13. Oracle-PLSQL提示“记录被另一个用户锁住”
  14. 【转】Android下使用配置文件(Preferences)
  15. Java使用POI读取和写入Excel指南
  16. Hibernate迫切左外连接和迫切内连接
  17. VNC Server (CentOS 7 GNOME)
  18. Qt——线程类QThread
  19. python字符中加入变量
  20. HDU4810_Wall Painting

热门文章

  1. Excel教程(9) - 信息函数
  2. UITextField的属性设置
  3. Smarty 注册变量
  4. android打包大小笔录
  5. Oracle结构知识学习+部分函数实例
  6. js函数大全(2)
  7. ReactiveCocoa常用方法
  8. Chapter 1 First Sight——31
  9. hdu_3067_小t的游戏(脑洞)
  10. Ubuntu14.04+cuda 7.5+cudnn_v4+tensorflow安装