我是angularjs的新手,我试图在angularjs中的dir-pagination-controls中创建固定的Page链接 我尝试使用'total-items = 100'但没有工作, 我从网络服务中获取了所有价值,
我尝试了什么
app.controller('listdata',['$scope', '$http', function($scope, $http) {
$scope.xxxx = []; //declare an empty array
data = [];
function getResultsPage(pageNumber) {
console.log('Please wait while data is loadind');
$http({
method: 'POST',
url: ajaxurl,
params: {
'action': 'get_xxxx',
'pageNumber': pageNumber,
'usersPerPage': $scope.usersPerPage
}
}).success(function (data, status, headers, config) {
$scope.xxxx = $scope.xxxx.concat(data);
$scope.totalUsers = 100;
});
}
$scope.users = [];
$scope.totalUsers = 0;
$scope.usersPerPage = usersPerPage; // this should match however many results your API puts on one page
getResultsPage(1);
$scope.pagination = {
current: 1
};
$scope.pageChanged = function(newPage) {
console.log(newPage);
getResultsPage(newPage);
};
$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
};
}]);
<tr dir-paginate="xxxx in xxxxs|orderBy:sortKey:reverse|filter:search|itemsPerPage:usersPerPage" >
<!--td>{{xxxx.id}}</td-->
<td>{{xxxx.name}}</td>
<td>{{xxxx.neighborhood}}</td>
<td class="td-edit"><img src="<?php echo esc_url(get_template_directory_uri()); ?>/dist/images/edit.png"></td>
</tr>
<dir-pagination-controls on-page-change="pageChanged(newPageNumber)"></dir-pagination-controls>