一、编写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. ADO.NET目录汇总1

    1.引用命名空间: using System.Data; using System.Data.SqlClient;[访问SQL Server定义的类] 2.连接字符串 string connectio ...

  2. <亲测>CentOS7yum安装PHP7.2

    如果之前已经安装我们先卸载一下 yum -y remove php* 由于linux的yum源不存在php7.x,所以我们要更改yum源 rpm -Uvh https://dl.fedoraproje ...

  3. RTB业务知识之1-原生广告

    一.背景 Native Advertising (Native Ads), 又称为原生广告, 是2013全球媒体界爆红的关键词,从2012年年底,就有人开始提了这个名词,接着到处都可以看到这个名词,再 ...

  4. MySQL 服务启动y异常: 本地无法启动MySQL服务,报的错误:1067,进程意外终止---解决

    启动MySQL后,几秒钟后直接报错了 然后在事件查看器中发现了几条错误信息 Can't start server: Bind on TCP/IP port: No such file or direc ...

  5. windows2008系统缓存修改

    Windwos Server 2008 中经常有物理内存占用较高,但任务管理器中各进程的内存看起来占用并不多情况. 这可能是由于OS为保证服务器性能不限制系统缓存,服务器系统长时间执行I/O,系统文件 ...

  6. slot内容分发

    vue实现了一套内容分发的API,这套API基于当前的web components规范草案,将<slot>元素作为承载分发内容的出口. 在前面的父子组件中,我们提到过,在vue中,组件实例 ...

  7. php中的各种http报错的报错的状态码的分析

    HTTP常见错误 HTTP 错误 400 400 请求出错 由于语法格式有误,服务器无法理解此请求.不作修改,客户程序就无法重复此请求. HTTP 错误 401 401.1 未授权:登录失败 此错误表 ...

  8. T-SQL 简单子查询

    1.使用变量的方式实现的查询 use StudentManageDB go declare @StuId int --查询张永利学号 select @StuId=StudentId from Stud ...

  9. Pyhton基础知识(一)

    Pyhton基础知识(一)一.cpu 内存 硬盘 操作系统之间的关系1.cpu 中央处理器 运算中心与控制中心 相当于人的大脑.2.内存 暂时存储数据 将应用程序加载到内存 以便于cpu进行数据传输交 ...

  10. javascript-添加 class 类 和 移出 class 类 方法

    /* 添加 class 类 和 移出 class 类 方法*/ function addClass(element, className) { if(!new RegExp("(^|\\s) ...