Update to support custom initial page load
I needed to use URL query to know in which page the user was. I put an initial page tag to know which page the user would like to open.
The tag would look like:
<div class="col-sm-12 pagination-container">
<dir-pagination-controls
class="pagination"
max-size="8"
initial-page="4"
direction-links="true"
boundary-links="true"
on-page-change="changePage(newPageNumber, meta.limit)">
</dir-pagination-controls>
</div>
I like it! :) please merge it!!
Hi, thanks for the PR.
Could your use case not be satisfied by using the current-page attribute and setting it to, say, 4 when the controller is initially loaded?
Hi!
That was my initial approach. I injected the pagination service in my controller to manually set the current page using the setCurrentPage(). But I needed the paginationId, which I did not know how to get. Ended up using the default value '__default' to solve the problem.
Anyway, I thought using that approach was a little bit hacky, since I had to look through the code and hard-code the pagination id in my controller, and had to inject the paginationService just to set the current page this one time. So I took the liberty to change the directive so that the logic remained there, without the need of external influences.
Well, I thought it could help someone, so I made this PR. It took me some time to discover how to do that.
Hi guys,
Sorry about the long delay. I still don't understand why you needed to get so hacky with the paginationService stuff. What about this: http://plnkr.co/edit/Cycne8sw1lRlMqpc0rRS?p=preview
Here I am simple setting the $scope.currentPage var to 4 in the controller, and declaring the current-page attribute on the dir-pagination directive. Does this not fit your needs?