Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support custom initial page load #356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gotolino
Copy link

@gotolino gotolino commented May 23, 2016

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 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.
@RobertHeim
Copy link

I like it! :) please merge it!!

@michaelbromley
Copy link
Owner

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?

@gotolino
Copy link
Author

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.

@michaelbromley
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants