I have a collection of ngbpanels that are dynamically created using ngFor. I need to expand or collapse a specific panel based on certain conditions, but the ID I provide for the panel is stored in a variable. The code does not recognize the panel ID when trying to toggle it. How can I format the variable so that it can be properly identified?
In the HTML file
<ngb-accordion #acc="ngbAccordion" >
<ngb-panel *ngFor="let panel of panels; let panelIndex=index" id="{{panelIndex}}">
....
In the TypeScript file:
@ViewChild('acc') panelsView;
....
this.panelsView.toggle(this.panelIndex);
The challenge lies in providing a string identifier like this: .toggle('panelId'), where 'panelId' represents the actual string ID of the panel. However, I need to pass a variable instead. I attempted .toggle(" '+this.panelIndex+' "), but it did not work as expected. Any suggestions?