Angular ui.bootstrap.pagination分頁
更新時間:2017年01月20日 16:19:15 作者:KingCruel
這篇文章主要為大家詳細介紹了Angular ui.bootstrap.pagination 分頁的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了Angular 分頁的具體代碼,供大家參考,具體內(nèi)容如下
1、Html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>MyPagination</title>
<link 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);
}
效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
詳解angularjs實現(xiàn)echart圖表效果最簡潔教程
本篇文章主要介紹了詳解angularjs實現(xiàn)echart圖表效果最簡潔教程,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
angular ng-repeat數(shù)組中的數(shù)組實例
下面小編就為大家?guī)硪黄猘ngular ng-repeat數(shù)組中的數(shù)組實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02
AngularJS的ng-repeat指令與scope繼承關(guān)系實例詳解
這篇文章主要介紹了AngularJS的ng-repeat指令與scope繼承關(guān)系,結(jié)合實例形式通過ng-repeat指令詳細分析了scope繼承關(guān)系,需要的朋友可以參考下2017-01-01
angularjs實現(xiàn)上拉加載和下拉刷新數(shù)據(jù)功能
本篇文章主要介紹了angularjs實現(xiàn)上拉加載和下拉刷新數(shù)據(jù)功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06
Angular 2.x學(xué)習(xí)教程之結(jié)構(gòu)指令詳解
結(jié)構(gòu)指令通過添加和刪除 DOM 元素來更改 DOM 布局。Angular 中兩個常見的結(jié)構(gòu)指令是 *ngIf 和 *ngFor,下面這篇文章主要給大家介紹了關(guān)于Angular 2.x結(jié)構(gòu)指令的相關(guān)資料,需要的朋友可以參考下。2017-05-05

