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.

ngbAccordion doesnt open panels from activeIds array when coming from another page with router

See original GitHub issue

hey, mates, pls can u help me in understanding why i cant display activeIds on ngbaccordion on another page while i using router(i have accordion with title name of projects, im going from accordion with click on title project, on main page, to another on another page) ? i try to catch em on OnInit, AfterView** hooks with “this.acc.activeIds = this.arr.map((el, i) => ngb-panel-${i});” but nothing happens. It works(panels are open) only when i reload page, although acc.activeIds already have had array with panels to open. I think im doing smth wrong or doesnt understand how to do with it.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
hillincommented, Apr 10, 2022

From future: this is a gotcha which we stumbled upon recently. The first time a ngbAccordion is loaded, it assigns the ids ngb-panel-0, ngb-panel-1ngb-panel-{{n}} to the panels by default (if they don’t have ids assigned manually); but when you take a detour to another page and come back again, these panels will have ids ngb-panel-{{n+1}}ngb-panel-{{2n + 1}}, so you can’t manipulate the panels with the old ids any more. The solution is to manually specify ids for the panels.

Since the documentation also exploits the default ids in the examples, I think this pitfall deserves a line in the documentation.

1reaction
kernydencommented, Sep 3, 2018

@benouat thx, also have done, stackblitz goes to reload page when i come back to previous path, but any way with click on project and go to second-page route mine acc.activeIds dont have open state. How i can fix this? any hook cant help me or provide directive to html as [activeIds], i tried( https://stackblitz.com/edit/angular-7g3yp5?file=src%2Fapp%2Facc-list%2Facc-list.component.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngbAccordion doesnt open panels from activeIds array when ...
I think I'm doing something wrong or doesn't understand how to do with it. Anyway with click on project and go to second-page...
Read more >
Sep 2017 - angular/angular - Gitter
I tried (helpAcc)="ngbAccordion" but that doesn't seem to work. ... because my panel IDs are numeric and css id can not start with...
Read more >
[Solved]-router navigate doesn't redirect to other page-angular.js
Coding example for the question router navigate doesn't redirect to other ... ngbAccordion doesnt open panels from activeIds array when coming from another...
Read more >
Accordion - Angular powered Bootstrap
Accordion is a collection of collapsible panels (bootstrap cards). ... Selector: 'ngb-accordion' ... Opening a new panel will close others. Type: boolean.
Read more >
angular 6 dynamic accordion example
Open the first attached expansion panel in an Angular Material. For drawing the chart First, ... I think activeIds can't see the change...
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