![](/img/trans.png)
[英]Bootstrap Carousel Transitions and Prev/Next Buttons Not Working
[英]AngularJS Pagination With Bootstrap Not Displaying Next/Prev Buttons
我正在嘗試使用AngularJS和Bootstrap對通過JSON獲得的數據進行分頁。 它的工作方式是僅顯示我想要的每頁編號,但是“下一個/上一個”和“編號”按鈕根本不顯示。 分頁標簽似乎在我的編輯器(Notepad ++)中甚至無法識別,我不確定這是否與它有關。 我目前正在IE中進行測試。 感謝您的幫助,因為我已經堅持了一段時間-謝謝!
這是我的HTML / JS:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NES- Home</title>
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body onload="getUrl()">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="Home.html"> Admin</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="Users.html">Users</a></li>
</ul>
<p class="nav navbar-text navbar-right"></p>
</div>
</div>
</div>
<form class="form-inline">
<div class="form-group">
<label >Search</label>
<input type="text" ng-model="search.Username" class="form-control" placeholder="Search">
</div>
</form>
<table class="table" ng-controller="myCtrl">
<tr>
<th ng-click="sort('Username')">Username</th>
<th ng-click="sort('Domain')">Domain</th>
<th ng-click="sort('GivenName')">Given Name</th>
<th ng-click="sort('Surname')">Surname</th>
</tr>
<tr ng-repeat="user in users.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage))|orderBy:sortKey:reverse|filter:search">
<td>{{user.Username}}</td>
<td>{{user.Domain}}</td>
<td>{{user.GivenName}}</td>
<td>{{user.Surname}}</td>
</tr>
</table>
<pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()" class="pagination-sm" items-per-page="itemsPerPage"></pagination>
<iframe id="iframe" src="Index.html" style="display:none"></iframe>
<script>
function getUrl() {
var uri= document.getElementById('iframe').contentWindow.document.getElementById('apiUri').value;
server = uri + (uri.last === "/" ? "" : "/");
}
var server;
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http({
method : "GET",
url : URL
}).then(function mySuccess(response) {
$scope.users = response.data;
$scope.viewby = 5;
$scope.totalItems = $scope.users.length;
$scope.currentPage = 1;
$scope.itemsPerPage = $scope.viewby;
$scope.maxSize = 5; //Number of pager buttons to show
});
$scope.sort = function(keyname){
$scope.sortKey = keyname; //set the sortKey to the param passed
$scope.reverse = !$scope.reverse; //if true make it false and vice versa
}
$scope.setPage = function (pageNo) {
$scope.currentPage = pageNo;
};
$scope.pageChanged = function() {
console.log('Page changed to: ' + $scope.currentPage);
};
$scope.setItemsPerPage = function(num) {
$scope.itemsPerPage = num;
$scope.currentPage = 1; //reset to first page
}
});
</script>
</body>
</html>
這是我遵循的示例,可以正常工作: http : //embed.plnkr.co/eheFSh/
ui-bootstrap需要Angular和Bootstrap CSS文件作為依賴項。 似乎您錯過了在代碼中鏈接bootstrap css文件的過程。
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.