I have a problem changing the chevron from UP to DOWN when clicking the accordion. It seems to always result to true no matter what trick I tried and even tried other examples like this https://stackblitz.com/edit/ngx-bootstrap-ifmpph?file=app%2Fapp.component.html
<accordion [closeOthers]="true">
<accordion-group #group [isOpen]='true'>
<div accordion-heading class="clearfix">
Basic Information
<span class="badge badge-secondary float-right pull-right">
<i class="fa" [ngClass]="!group?.isOpen ? 'fa-chevron-down': 'fa-chevron-down'"></i>
</span>
</div>
</accordion-group>
</accordion>
this one works:
<accordion>
<accordion-group #group1 [isOpen]='true'>
<div accordion-heading class="clearfix">
Basic Information
<span class="badge badge-secondary float-right pull-right">
<i class="fa" [ngClass]="{'fa-chevron-up': group1.isOpen, 'fa-chevron-down': !group1.isOpen}"></i>
</span>
</div>
</accordion>
I'm not sure if this is a best solution, but it is working for me:
<ngb-accordion #accordion [closeOthers]="true" >
<ngb-panel *ngFor="let round of data, let i=index">
<ng-template ngbPanelTitle>
<div class="d-flex flex-row justify-content-between" style="width: 100%">
<div class="p-2">
{{round.title}}
</div>
<div class="p-2">
<span [ngClass]="{'icon-arrow-up': accordion.panels._results[i].isOpen, 'icon-arrow-down': !accordion.panels._results[i].isOpen}"></span>
</div>
</div>
</ng-template>
<ng-template ngbPanelContent>
{{round.info}}
</ng-template>
</ngb-panel>
</ngb-accordion>
Take a look to accordion.panels._results[i].isOpen. Also, add to component.ts:
import { AccordionComponent } from 'ngx-bootstrap';
...
@ViewChild('accordion') accordion: AccordionComponent;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With