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.

multiple Accordion's build with ngFor ['Element': '#3.1' is not a valid selector.]

See original GitHub issue

Bug description:

  • in template(html) I want multiple accordions buld with for lop, how to define them in typescript
  • in typescript I want for specific accordion to toggel specific panel

is this even possible?

  • HTML:
<div class="panel-group"
         *ngFor="let fqa of faqs, let i = index">

        <h5 [id]="fqa.id">{{fqa.section}}</h5>

        <ngb-accordion #acc="ngbAccordion"
                       [id]="fqa.id">
            <ngb-panel *ngFor="let q of fqa.qa"
            [id]="q.id"
                       title="V: {{q.question}}">

                <ng-template ngbPanelContent>
                    <span class="badge badge-primary">O:</span>&nbsp;
                    <span style="text-align: justify"
                          [innerHtml]="q.answer"></span>
                </ng-template>
            </ngb-panel>
        </ngb-accordion>
</div>
  • typescript:
@ViewChildren('acc')
  accordions: QueryList<NgbAccordion>;
  • error:
Failed to execute 'querySelector' on 'Element': '#1.1' is not a valid selector.
    at NgbAccordion._getPanelElement (http://localhost:4200/vendor.js:1874:44)

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 13

ng-bootstrap: 10.0.0

Bootstrap: 4.6.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
sysmatcommented, Dec 8, 2021
  • sorry it was my mistake, I query the wrong accordion, and then there was no panel with the desired id, it works
  • the only suggestion is when using toggle I get infinite times x msg in logs and reopening panel
1reaction
ExFlocommented, Dec 7, 2021

Hi First you shouldn’t use the id at two points here <h5 [id]=“fqa.id”> and <ngb-accordion #acc=“ngbAccordion” [id]=“fqa.id”>

If will fix the issue the issue in ng-bootstrap. Meanwhile using a char as first character in the id is a workaround. This is the issue you have with the Panel --> start with a char will work. Thing is explained here: https://mathiasbynens.be/notes/css-escapes Best regards Florent

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use ngb-accordion in a ngFor loop? - Stack Overflow
I want make it possible that when one of the accordion elements includes the property 'OpenAccordion' the panel of that element opens. So...
Read more >
angular/angular - Gitter
I have a component with a custom ValueAccessor and if I put any validation on top of it it doesnt work.
Read more >
Release notes v2.0.0 - Alfresco Builder Network
These release notes provide information for the 2.0.0 release of the Alfresco Application Development Framework. This is the first General Available release ...
Read more >
Angular 2+ Notes for Professionals - Ketabton
not a liated with o cial Angular 2+ group(s) or company(s). ... For each element in the array, *ngFor creates a...
Read more >
JDI Light Framework - GitHub Pages
JDI Light is a powerful Test Automation Framework that helps to make your tests ... is valid for the logout button on Contact...
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