一、编写angularJS实现的分页js(网上搜)和样式表(pagination),并在页面引入

二、编写变量和方法

//分页控件控制
$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('../brand/getBrandByPage.do?page='+page+'&size='+size).success(//后台基于pageHelper实现的分页数据获取
function(res){
$scope.list = res.rows;//显示当前页数据
$scope.paginationConf.totalItems=res.total;//更新总记录数
}
)
}

三、引入分页变量

                        <tm-pagination conf="paginationConf"></tm-pagination>

页面

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>品牌管理</title>
<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
<link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
<link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="../css/style.css">
<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap.min.js"></script> <script type="text/javascript" src="../plugins/angularjs/angular.min.js"></script>
<script type="text/javascript" src="../plugins/angularjs/pagination.js"></script> <link rel="stylesheet" href="../plugins/angularjs/pagination.css"/>
<script type="text/javascript">
var app = angular.module('eshop',['pagination']);
app.controller('brandController',function($scope,$http){
//获取查询数据
$scope.findAll= function(){
$http.get('../brand/getAllBrand.do').success(
function(res){
$scope.list = res;
}
)
}; //分页控件控制
$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('../brand/getBrandByPage.do?page='+page+'&size='+size).success(
function(res){
$scope.list = res.rows;//显示当前页数据
$scope.paginationConf.totalItems=res.total;//更新总记录数
}
)
}
});
</script>
</head>
<body class="hold-transition skin-red sidebar-mini" ng-app="eshop" ng-controller="brandController" >
<!-- .box-body -->
<div class="box-header with-border">
<h3 class="box-title">品牌管理</h3>
</div> <div class="box-body"> <!-- 数据表格 -->
<div class="table-box"> <!--工具栏-->
<div class="pull-left">
<div class="form-group form-inline">
<div class="btn-group">
<button type="button" class="btn btn-default" title="新建" data-toggle="modal" data-target="#editModal" ><i class="fa fa-file-o"></i> 新建</button>
<button type="button" class="btn btn-default" title="删除" ><i class="fa fa-trash-o"></i> 删除</button>
<button type="button" class="btn btn-default" title="刷新" onclick="window.location.reload();"><i class="fa fa-refresh"></i> 刷新</button>
</div>
</div>
</div>
<div class="box-tools pull-right">
<div class="has-feedback"> </div>
</div>
<!--工具栏/--> <!--数据列表-->
<table id="dataList" class="table table-bordered table-striped table-hover dataTable">
<thead>
<tr>
<th class="" style="padding-right:0px">
<input id="selall" type="checkbox" class="icheckbox_square-blue">
</th>
<th class="sorting_asc">品牌ID</th>
<th class="sorting">品牌名称</th>
<th class="sorting">品牌首字母</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="entity in list">
<td><input type="checkbox" ></td>
<td>{{entity.id}}</td>
<td>{{entity.name}}</td>
<td>{{entity.firstChar}}</td>
<td class="text-center">
<button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#editModal" >修改</button>
</td>
</tr>
</tbody>
</table>
<!--数据列表/--> </div>
<!-- 数据表格 /-->
<tm-pagination conf="paginationConf"></tm-pagination> </div>
<!-- /.box-body --> <!-- 编辑窗口 -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">品牌编辑</h3>
</div>
<div class="modal-body">
<table class="table table-bordered table-striped" width="800px">
<tr>
<td>品牌名称</td>
<td><input class="form-control" placeholder="品牌名称" > </td>
</tr>
<tr>
<td>首字母</td>
<td><input class="form-control" placeholder="首字母"> </td>
</tr>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-success" data-dismiss="modal" aria-hidden="true">保存</button>
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
</div>
</div>
</div>
</div> </body>
</html>

Angular.js实现分页的更多相关文章

  1. angular JS 做分页

    在网上找了一天,连一个像样点的分页DEMO都没找到,晕死了.大部分都是相互抄,有各种各样的问题,要不是代码有BUG,要不就是解释不明,GITHUB上下载下来的总是乱糟糟的.心累.

  2. Angular.js+Bootstrap实现表格分页

    最近一直学习Angular.js,在学习过程中也练习了很多的Demo,这里先贴一下表格+分页. 先上图看看最终结果: 不得不说Angular.js代码风格很受人欢迎,几十行代码清晰简洁的实现了上面的功 ...

  3. angular.js分页代码的实例

    对于大多数web应用来说显示项目列表是一种很常见的任务.通常情况下,我们的数据会比较多,无法很好地显示在单个页面中.在这种情况下,我们需要把数据以页的方式来展示,同时带有转到上一页和下一页的功能.现在 ...

  4. Angular.js+Bootstrap实现手风琴菜单

    说是Angular.js+Bootstrap实现手风琴菜单,其实就是用了Bootstrap的样式而已. 上一篇实现了表格+分页,接着学习实现的Demo. 主要练习自定义指令,向指令中传递参数,老规矩先 ...

  5. angular.js的一点理解

    对angular.js的一点理解 2015-01-14 13:18 by MrGeorgeZhao, 317 阅读, 4 评论, 收藏, 编辑 最近一直在学习angular.js.不得不说和jquer ...

  6. angular.js 渲染

    angular.js 小常识   具体看代码,转载请备注来源. html结构 <%@ page language="java" contentType="text/ ...

  7. 在angular中利用分页插件进行分页

    必需:angular分页js和css  当然还有angular.js   还需要bootstrap的css angular.min.js (下面我直接把插件粘贴上去了,以免有的同学还要去找.是不是很贴 ...

  8. 对angular.js的一点理解

    最近一直在学习angular.js.不得不说和jquery相比有很大不同,有很多的不同点,之前也用过Knockout.js 但是两者还是有一定的区别的,首先knockout.js是基于Mvvm的,是几 ...

  9. Angular.js路由 简单小案例

    代码案例: <html> <head> <meta charset="utf-8"> <title>AngularJS 路由实例&l ...

随机推荐

  1. C#实现设置系统时间

    using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Demo { pub ...

  2. Azure ARM (15) 根据现有VHD文件,创建ARM VM

    <Windows Azure Platform 系列文章目录> 在很多时候,我们需要根据现有VHD文件,创建ARM VM.在这里笔者简单介绍一下相关的Azure PowerShell 这里 ...

  3. VUEX 学习

    语法   翻译  功能介绍 module(模块)extend(扩展)extract(提取)export(输出)router(路由器)components(组件) store(储存)state (声明. ...

  4. 机器学习笔记——t分布知识点总结

    (原创文章,转载请注明地址:http://www.cnblogs.com/wangkundentisy/p/6539058.html ) 1.t分布式统计分布的一种,同卡方分布(χ2分布).F分布并称 ...

  5. MyBatis 值的传递

    1.值的传递 - Map传值 可以通过对象获取Map传递值,在配置文件中通过 #{} 或 ${} 进行应用 查询30-40岁的用户 <!-- 值的传递 - Map传值 --> <se ...

  6. 文档碎片及xml讲解

    1.将数据渲染到页面的几种方式 1.字符串拼接 2.dom循环 3.模板 4.文档碎片 字符串拼接: 优势:只进行一次dom回流 缺点:原有的dom事件会消失 案例分析:原有list中有3个li,并且 ...

  7. Maven的classifier作用

    classifier可以是任意的字符串,用于拼接在GAV之后来确定指定的文件. 可用于区分不同jdk版本所生成的jar包 <dependency> <groupId>net.s ...

  8. 一个简单的基于多进程实现并发的Socket程序

    在单进程的socket的程序的基础上,实现多进程并发效果的思路具体是:在server端开启“链接循环”,每建立一次链接就生成一个Process对象进行server-client的互动,而client端 ...

  9. Linux下安装python3及相关包

    Python3: sudo apt-get install python3 终端中输入python则进入python2,输入python3则进入python3 安装python2的相关包: sudo ...

  10. C#存储过程中传入传出参数

    作者:卞功鑫  ,转载请保留http://www.cnblogs.com/BinBinGo/p/6399847.html //1 连接字符串 string connectionString = &qu ...