gpt4 book ai didi

javascript - Bootstrap 的 AngularJS 分页不显示下一个/上一个按钮

转载 作者:行者123 更新时间:2023-12-03 02:10:02 27 4
gpt4 key购买 nike

我正在尝试使用 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">

关于javascript - Bootstrap 的 AngularJS 分页不显示下一个/上一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49617708/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com