所以我使用angularjs来显示从mysql检索到的内容。我试图用angularjs创建一个分页,在每个页面上显示一定数量的页面。我的问题是,在视图中,它根据我在控制器中定义的限制显示内容,但是,它没有显示我可以用来在页面中导航的页码。有什么想法吗???
这是我的密码:
<!-- the VIEW -->
<div class="container testing" ng-controller="musicControl">
<table>
<tr ng-repeat="post in posts | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
<td style="padding:15px">{{ post.postType }}</td>
<td style="padding:15px">{{ post.postTitle | uppercase }}</td>
<td style="padding:15px">{{ post.postDescription }}</td>
<td style="padding:15px">{{ post.postDate | date }}</td>
<td style="padding:15px">
<?php
include "functions.php";
placeMusic('{{ post.src | trustAsResourceUrl }}');
?>
</td>
</tr>
</table>
<div ng-show="filteredItems > entryLimit">
<div pagination="" page="currentPage"
on-select-page="setPage(page)"
boundary-links="true" total-items="filteredItems"
items-per-page="entryLimit"
class="pagination-small" previous-text="«"
next-text="»">
</div>
</div>
<br>
</div>
模块-->
var app = angular.module("myApp", ["ngRoute"]);
<!-- controller -->
app.controller('musicControl', function($scope, $http) {
$http.get("pages/db_section/music.php")
.then(function (response) {
$scope.posts = response.data.records;
$scope.currentPage = 1; //current page
$scope.entryLimit = 2; //max no of items to display in a page
$scope.filteredItems = $scope.posts.length; //Initially for no filter
$scope.totalItems = $scope.posts.length;
});
$scope.setPage = function(pageNo) {
$scope.currentPage = pageNo;
};
});
<!-- filter -->
app.filter('trustAsResourceUrl', ['$sce', function($sce) {
return function(val) {
return $sce.trustAsResourceUrl(val);
};
}]);
app.filter('startFrom', function() {
return function(input, start) {
if(input) {
start = +start; //parse to int
return input.slice(start);
}
return [];
}
});
暂无答案!
目前还没有任何答案,快来回答吧!