我想在我的應用程序中使用服務器端分頁,但由於分頁選項丟失,我無法做到這一點。我正在使用這tutorial 分頁。dirPagination - 不顯示分頁鏈接?
這裏是我的代碼:
的JavaScript:
$scope.vm={};
// var vm = this;@TODO
$scope.vm.users = []; //declare an empty array
$scope. vm.pageno = 1; // initialize page no to 1
$scope. vm.total_count = 0;
$scope.vm.itemsPerPage = 10; //this could be a dynamic value from a drop down
$scope.getData = function(pageno){ // This would fetch the data on page change.
//In practice this should be in a factory.
$scope.vm.users = [];
//$http.get("http://localhost:8093/ProductLicensingApplication/pagingList/{itemsPerPage}/{pagenumber}").success(function(response){
// //ajax request to fetch data into vm.data
// vm.users = response.data; // data to be displayed on current page.
// vm.total_count = response.total_count; // total data count.
//});
var params = {
pageno: $scope.vm.pageno,
itemsPerPage: $scope.vm.itemsPerPage
};
featureService.getPagingFeatures(params).then(function (response) {
console.log("Getting paging Feature list..");
console.log(response.status);
if (response.status.name == "OK") {
$scope.vm.users = response.pagingFeaturesList; // data to be displayed on current page.
$scope.vm.total_count = response.total_count; // total data count.
console.log("paging success");
console.log($scope.vm.users);
console.log($scope.vm.total_count);
} else {
}
}, function (error) {
console.log(error);
});
};
$scope.getData($scope.vm.pageno);
HTML:
<table class="table table-striped table-hover">
<thead>
<tr>
<th> SR# </th>
<th> Name </th>
<th> Code </th>
<th> Description </th>
<th> is Active </th>
</tr>
</thead>
<tbody>
<tr ng-show="vm.users.length <= 0"><td colspan="5" style="text-align:center;">Loading new data!!</td></tr>
<tr dir-paginate="user in vm.users|itemsPerPage:vm.itemsPerPage" total-items="vm.total_count">
<td> {{$index+1}}</td>
<td>{{user.name}}</td>
<td>{{user.code}}</td>
<td> {{user.description}}</td>
<td> {{user.isActive}}</td>
</tr>
</tbody>
</table>
<dir-pagination-controls
max-size="10"
direction-links="true"
boundary-links="true"
on-page-change="vm.getData(newPageNumber)" >
</dir-pagination-controls>
請告訴我怎麼加在我桌子下面的分頁鏈接,我已經去了通過堆棧溢出和谷歌不同的解決方案,但它不適合我。
你使用controllerAs還是scope? – Akashii
我不確切地知道你在問什麼? – Ahmad
你可以檢查控制檯是否有任何錯誤? – MehulJoshi