Angular ui.bootstrap.pagination分页


Posted in Javascript onJanuary 20, 2017

本文实例为大家分享了Angular 分页的具体代码,供大家参考,具体内容如下

1、Html

<!DOCTYPE html> 
 
<html> 
<head> 
 <meta name="viewport" content="width=device-width" /> 
 <title>MyPagination</title> 
 <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" /> 
 <script src="~/Scripts/angular.js"></script> 
 <script src="~/Scripts/ui-bootstrap-tpls-0.13.0.min.js"></script> 
 <script> 
  var readyDataUrl = '@Url.Content("~/StudentManage/GetPageList")'; 
  var loadDataUrl = '@Url.Content("~/StudentManage/GetPageList")'; 
  var app = angular.module('app', ['ui.bootstrap']); 
  app.controller('ctrl', ['$log', '$http', '$scope', function ($log, $http, $scope) { 
   $scope.reportData = []; 
   $scope.maxSize = 7; 
   $scope.currentPage = 0; 
   $scope.totalItems = 0; 
   $scope.pageChanged = function () { 
    //showLoading("正在查询"); 
    $http.post(loadDataUrl, { 
     pageIndex: $scope.currentPage, 
     pageSize: 10, 
     name: "" 
    }) 
     .then(function (result) { 
      $scope.reportData = result.data.Data; 
      $scope.totalItems = result.data.recordTotal; 
     }).catch(function (error) { 
      $log.error('error:' + error); 
     }).finally(function () { 
      //closeLoading(); 
     }); 
   } 
   $scope.Inital = function () { 
    //showLoading("正在查询"); 
 
    $http.post(readyDataUrl, { 
     pageIndex: $scope.currentPage, 
     pageSize: 10, 
     name: "" 
    }).then(function (result) { 
     $scope.reportData = result.data.Data; 
     $scope.totalItems = result.data.recordTotal; 
     //closeLoading(); 
    }).catch(function (error) { 
     $log.error('error:' + error); 
    }).finally(function () { 
 
    }); 
   } 
   $scope.Inital(); 
   $scope.search = function () { 
    //showLoading("正在查询"); 
    $http.post(loadDataUrl, {}) 
     .then(function (result) { 
      $scope.reportData = result.data.Data; 
      $scope.totalItems = result.data.recordTotal; 
     }).catch(function (error) { 
      $log.error('error:' + error); 
     }).finally(function () { 
      //closeLoading(); 
     }); 
   } 
  }]); 
 </script> 
</head> 
<body> 
 <div ng-app="app" ng-controller="ctrl"> 
  <div class="form-group" id="toolbar"> 
   <table> 
    <tr> 
     <td style="padding-left:10px;"> 
      <button type="button" class="btn btn-success btn-sm" id="btnSearch" ng-click="search()">查询</button> 
     </td> 
    </tr> 
   </table> 
   <div class="bootstrap-table"> 
    <div class="fixed-table-container" style="padding-bottom: 0px;"> 
     <div class="table-responsive"> 
      <table class="table table-condensed table-hover table-striped"> 
       <thead> 
        <tr> 
         <th><div class="th-inner">序号</div></th> 
         <th><div class="th-inner">姓名</div></th> 
         <th><div class="th-inner">电话</div></th> 
         <th><div class="th-inner">邮箱</div></th> 
         <th><div class="th-inner">年龄</div></th> 
         <th><div class="th-inner">国家</div></th> 
         <th><div class="th-inner">城市</div></th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr ng-repeat="o in reportData"> 
         <td><span ng-bind="o.Id"></span></td> 
         <td><span ng-bind="o.Name"></span></td> 
         <td><span ng-bind="o.Telephone"></span></td> 
         <td><span ng-bind="o.Email"></span></td> 
         <td><span ng-bind="o.Age"></span></td> 
         <td><span ng-bind="o.Country"></span></td> 
         <td><span ng-bind="o.City"></span></td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 
    </div> 
   </div> 
   <pagination class="pagination-sm pull-right" 
      ng-model="currentPage" 
      total-items="totalItems" 
      max-size="7" 
      ng-change="pageChanged()" 
      force-ellipses="true" 
      num-pages="numPages" 
      boundary-link-numbers="true" 
      boundary-links="false" @*是否显示第一个/最后一个按钮*@ 
      rotate="false" 
      previous-text="‹" 
      next-text="›"> 
   </pagination> 
  </div> 
 </div> 
</body> 
</html>

2、Action

[HttpPost] 
public JsonResult GetPageList(int pageIndex, int pageSize, string name) 
{ 
 int pageCount = 1; 
 int recordTotal = 0; 
 int topRecordTotal = 0; 
 List<Students> list = new List<Students>(); 
 try 
 { 
  list = svc.GetAllStudent(); 
  recordTotal = list.Count(); 
  pageCount = (int)Math.Ceiling((decimal)recordTotal / pageSize); 
  topRecordTotal = (pageIndex - 1 < 0 ? 0 : pageIndex - 1) * pageSize; 
  list = list.Skip(topRecordTotal).Take(pageSize).ToList(); 
 } 
 catch (Exception) 
 { 
  throw; 
 } 
 return Json(new 
 { 
  pageIndex = pageIndex, 
  pageCount = pageCount, 
  recordTotal = recordTotal, 
  Data = list, 
 }, JsonRequestBehavior.AllowGet); 
}

效果图:

Angular ui.bootstrap.pagination分页

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
css把超出的部分显示为省略号的方法兼容火狐
Jul 23 Javascript
js控制CSS样式属性语法对照表
Dec 11 Javascript
asp.net中System.Timers.Timer的使用方法
Mar 20 Javascript
JavaScript中变量声明有var和没var的区别示例介绍
Sep 15 Javascript
js如何打印object对象
Oct 16 Javascript
JavaScript简单实现鼠标移动切换图片的方法
Feb 23 Javascript
基于Echarts 3.19 制作常用的图形(非静态)
May 19 Javascript
js实现StringBuffer的简单实例
Sep 02 Javascript
Vue.js 2.0 和 React、Augular等其他前端框架大比拼
Oct 08 Javascript
原生js更改css样式的两种方式
Mar 15 Javascript
Angular排序实例详解
Jun 28 Javascript
react-native使用leanclound消息推送的方法
Aug 06 Javascript
bootstrap中的 form表单属性role=&quot;form&quot;的作用详解
Jan 20 #Javascript
javascript容错处理代码(屏蔽js错误)
Jan 20 #Javascript
关于AngularJs数据的本地存储详解
Jan 20 #Javascript
html5 canvas 详细使用教程
Jan 20 #Javascript
canvas绘制万花筒效果(代码分享)
Jan 20 #Javascript
原生js实现网页顶部自动下拉/收缩广告效果
Jan 20 #Javascript
Angular.js中ng-if、ng-show和ng-hide的区别介绍
Jan 20 #Javascript
You might like
判断是否为指定长度内字符串的php函数
2010/02/16 PHP
PHP-Java-Bridge使用笔记
2014/09/22 PHP
jquery struts 验证唯一标识(公用方法)
2013/03/27 Javascript
js调用css属性写法
2013/09/21 Javascript
js拖拽一些常见的思路方法整理
2014/03/19 Javascript
jQuery应用之jQuery链用法实例
2015/01/19 Javascript
在其他地方你学不到的jQuery小贴士和技巧(欢迎收藏)
2016/01/20 Javascript
个人网站留言页面(前端jQuery编写、后台php读写MySQL)
2016/05/03 Javascript
javascript弹出窗口中增加确定取消按钮
2016/06/24 Javascript
nodejs socket服务端和客户端简单通信功能
2017/09/14 NodeJs
JS实现图片居中悬浮效果
2017/12/25 Javascript
JS随机数产生代码分享
2018/02/24 Javascript
JS字符串去除连续或全部重复字符的实例
2018/03/08 Javascript
JS中双击和单击事件冲突的解决方法
2018/04/09 Javascript
vue 点击按钮实现动态挂载子组件的方法
2018/09/07 Javascript
VueJS 组件参数名命名与组件属性转化问题
2018/12/03 Javascript
jQuery实现表格的增、删、改操作示例
2019/01/27 jQuery
vue+Element中table表格实现可编辑(select下拉框)
2020/05/21 Javascript
Python中生成器和迭代器的区别详解
2018/02/10 Python
python 字典中文key处理,读取,比较方法
2018/07/06 Python
详解windows python3.7安装numpy问题的解决方法
2018/08/13 Python
python实现windows壁纸定期更换功能
2019/01/21 Python
python+Django+pycharm+mysql 搭建首个web项目详解
2019/11/29 Python
python中remove函数的踩坑记录
2021/01/04 Python
HTML5 本地存储和内容按需加载的思路和方法
2011/04/07 HTML / CSS
canvas实现高阶贝塞尔曲线(N阶贝塞尔曲线生成器)
2018/01/10 HTML / CSS
非凡女性奢华谦虚风格:The Modist
2017/10/28 全球购物
美国户外运动商店:Sun & Ski
2018/08/23 全球购物
英国最大最好的无人机商店:Drones Direct
2019/07/12 全球购物
满月酒答谢词
2014/01/14 职场文书
文明餐桌行动实施方案
2014/02/19 职场文书
2016年“世界气象日”广播稿
2015/12/17 职场文书
高中班主任工作总结(范文)
2019/08/20 职场文书
python 如何将两个实数矩阵合并为一个复数矩阵
2021/05/19 Python
python基于turtle绘制几何图形
2021/06/15 Python
Python时间操作之pytz模块使用详解
2022/06/14 Python