I've been trying to incorporate dir-pagination-controls
, but can't work display the page based on the chosen page.
<div ng-controller="TableController as tc">
<table>
<tbody dir-paginate="order in tc.orders | itemsPerPage: 10" total-items="tc.totalOrders" current-page="currentPage">
<tr ng-click="tc.showOrderDetail(order.id)">
<td ng-bind="order.id"></td>
<!-- Simliar lines are here -->
</tr>
</tbody>
</table>
<dir-pagination-controls
boundary-links="true"
on-page-change="tc.pageChangeHandler(newPageNumber)"
template-url="dirPagination.tpl.html">
</dir-pagination-controls>
</div>
This table
shows what I expect. However, the resulting pagination controller doesn't show the next page when I press any of its buttons.
Here is a relevant part of the script.
angular.module('adminAngular', ['ui.bootstrap','dialogs.main','angularUtils.directives.dirPagination'])
.controller('TableController', function($http){
var instance = this;
this.orders = [];
$http({
//works fine
}).then(function (response) {
instance.orders = response.data;
instance.totalOrders = instance.orders.length;
//The "instance.orders" gets the expected data, and used for in dir-paginate="order in tc.orders
});
this.pageChangeHandler = function(num) {
console.log('going to page ' + num);
};
this.pageChanged = function(newPage) {
getResultsPage(newPage);
};
UPDATE The pageChangeHandler
shows which button was pressed, but the page doesn't change. (Everything else is fine.)
This code is based on the official document and its demo,but I can't find what is actually wrong.
I'd appreciate if you give any advice.