question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autoHide doesn't work in custom templates

See original GitHub issue

Angular 2 version: 2.0.0

ng2-pagination version: 0.5.1

Description of issue: autoHide feature doesn’t work while using custom template. I whether get three links — Previous, 1, and Next, or only two — Previous and Next if there are no collection items on a page. So then I added ngIf to my template to check if there are any pages in pagination and got the following: if pagination should be hidden it is hidden, but if it should be shown both mine and default templates are shown.

I use custom pug-template such as:

pagination-controls(ref-pagination autoHide="true")
  nav.text-center(*ngIf="pagination.pages.length > 1" aria-label="Page navigation")

    p hasTemplate: {{pagination.hasTemplate}}

    ul.pagination.pagination-sm

      li([class.disabled]="pagination.isFirstPage()")
        a((click)="pagination.previous()" aria-label="Previous")
          span(aria-hidden="true") «

      li(*ngFor="let page of pagination.pages", [class.active]="pagination.getCurrent() === page.value")
        a([routerLink]="{page: page.label}") {{page.label}}

      li([class.disabled]="pagination.isLastPage()")
        a("(click)"="pagination.next()" aria-label="Next")
          span(aria-hidden="true") »

The hasTemplate is always falsy.

I use paginate pipe such as:

div(*ngFor="let theme of themes | paginate: {itemsPerPage:20, currentPage:p, totalItems: themesTotalCount}")

I get themes from server but not using the async pipe.

With default template autoHide works as expected.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
michaelbromleycommented, Oct 25, 2016

Hi, Thanks for the report. I’ve been thinking about changing the way custom templates are handled. After using this lib in some of my own projects, I found it easier just to wrap the entire PaginationsControlsCmp in my own custom component.

So I am thinking it might be better to offer either a directive or modify the service, to make it simpler to do custom templating. The default template would continue to be available as a component for convenience.

I may get time to work on this later this week.

1reaction
michaelbromleycommented, Jul 26, 2017

@badcoder28 Hi, take a look the docs - “autoHide” is not part of the directive API, which only has 2 inputs: “id” and “maxSize”.

In order to get something like “autoHide” in your own custom template, you’ll need to implement it yourself. This is pretty simple. Take a look at how it is done in the default controls component for an idea:

component code

template code

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Password Template to Auto-Hide Data in Worksheets
This tutorial is another take on how to use a password to protect your data and to make it magically appear and disappear...
Read more >
[DEPENDS ON EVERY TEMPLATE] auto hide empty custom ...
Is it possible to automatically hide empty custom fields from being shown in the article? I have several custom fields around, but I...
Read more >
Custom Password Template to Auto-Hide Data in Worksheets
Excel VBA/Macro Course! [On Sale]: https://www.teachexcel.com/vba-course-update.php?src=youtube_v_description_XRfQB1HEuMkDownload the File: ...
Read more >
autohide an element in VueJS after 1 second - Stack Overflow
Method Created called synchronously after the instance is created. <template> <div> <h1 v-show="elementVisible" class="hideElement"> HELLO </h1> ...
Read more >
Task bar auto hide isn't working correctly - Microsoft Community
Whenever I'm in a maximized application like Firefox, Discord, Steam, etc., the task bar will not unhide when I move my mouse to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found