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.

NavTabs: Don't destroy on hide but initialise only on click

See original GitHub issue

Bug description:

I have a page with a lot of tabs and each one has its own reactive forms and http calls to initialise those forms. When I open a tab and go back and forth to that tab i dont want it to re-initialise since i might have some filters that i want them to stay as they are left. The input property destroyOnHide looked promising but the thing is that all tabs are initialised at the page load even if the user does not navigate to them. This results to a bad page loading time. Ideally, i want the tabs to be initialised only on select, and destroy only when the user navigates to a different url route.

Link to minimally-working StackBlitz that reproduces the issue:

I believe the description is enough but in case you have different opinion, I can provide with a demo

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 9 ng-bootstrap: 6 Bootstrap: 4

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jnizetcommented, Jul 17, 2020

You can do that pretty easily by just keeping a set of visited IDs (thanks to the activeIdChange output), and only displaying the content of a tab (thanks to *ngIf) if its ID is in the set of visited Ids.

Here’s a demo: https://stackblitz.com/edit/angular-fg9wda?file=src%2Fapp%2Fnav-keep-content.ts

0reactions
maxokorokovcommented, Aug 20, 2020

Looks like a duplicate of #1584 to me. Lazy initialization is not implemented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my Bootstrap 4 tabs don't deactivate? - Stack Overflow
Once clicked, every tab stays active and highlighted until reloading the page. What should I do to make sure only one tab can...
Read more >
JavaScript - Bootstrap
Bootstrap's plugins don't fall back particularly gracefully when JavaScript is disabled. ... Toggle a modal via JavaScript by clicking the button below.
Read more >
JavaScript · Bootstrap 3.2.0 Documentation - BootstrapDocs
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .open class on the parent list item....
Read more >
Angular directives for Bootstrap - AngularUI
As a result no dependency on jQuery or Bootstrap's JavaScript is required. The only required dependencies are: AngularJS (requires AngularJS 1.4.x or higher, ......
Read more >
Tabs - Materialize
The tabs structure consists of an unordered list of tabs that have hashes corresponding to tab ids. Then when you click on each...
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