点击手风琴时,我将V形图从UP更改为DOWN时出现问题。无论我尝试过哪种技巧,甚至尝试过像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>
答案 0 :(得分:2)
我不确定这是否是最好的解决方案,但是它对我有用:
<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>
看看 accordion.panels._results [i] .isOpen 。 另外,添加到component.ts:
import { AccordionComponent } from 'ngx-bootstrap';
...
@ViewChild('accordion') accordion: AccordionComponent;
答案 1 :(得分:0)
这是可行的:
<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>