Reputation: 2062
I used dir-paginate for the first time in angularJS and it was very easy to have a pagination that works as desired... Until I noticed a small problem. The items are now correctly paginated, when I go in the details of an Item (a row) I have a button "back" that should bring me on the page where the item was.
For example, if I am on page 4 and click on any item, I go to a page with its details, then I want to create a button "back" that should bring the user to page 4.
The code of my table is quite easy, I just used dir-paginate on the item list and added at the end of the page. On the button I wanted to create, I tried to use setCurrent(4) - for now using a fix number, but nothing happens. I suppose because detail page is in a totally different page and the pagination is not visible from there.
I just had to change my table into something like this:
<table class="mytable">
<thead>
<tr> headers th..</tr>
</thead>
<tbody>
<tr dir-paginate="record in filteredData = (data | itemsPerPage: 20)"> columns... </tr>
</tbody>
</table>
<dir-pagination-controls></dir-pagination-controls>
how could I go directly to page X of such table?
Upvotes: 0
Views: 71
Reputation: 2062
I found that the new button works if in the controller, the function paginationService.setCurrentPage is called in $timeout, as following:
$timeout(function() {
paginationService.setCurrentPage('__default', thePage));
});
Of course after importing $timeout object.
So I created a wrapper as following:
vm.setCurrentPagination = function(numeroPagina){
$timeout(function () {
paginationService.setCurrentPage('__default', numeroPagina);
});
};
I found here the trick: how to set currentpage to be last with dir-paginate
Upvotes: 0