NavTabs: Don't destroy on hide but initialise only on click
See original GitHub issueBug 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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
Looks like a duplicate of #1584 to me. Lazy initialization is not implemented.