According to PrimeNG documentation, it's necessary using an array of numbers that define the indexes of active tabs. However, there is no example about its usage, and I am having issues with that.
I have a cancel button that have to open two accordions if clicked. However, it does not work when I click. It has no action. Is there any behavior that I am missing, or doing it wrongly?
- My accordion:
Code: Select all
<p-accordion [activeIndex]="accordionIndex" [multiple]="true" (onOpen)="onTabOpen($event)">
<p-accordionTab header="Header 0" [selected]="true">
<app-new-services-cover></app-new-services-cover>
</p-accordionTab>
<p-accordionTab header="Header 1">
</p-accordionTab>
<p-accordionTab header="Header 2">
</p-accordionTab>
<p-accordionTab header="Header 3">
</p-accordionTab>
<p-accordion>
...
Code: Select all
<button pButton type="button" label="Cancelar" (click)="onCancel()"></button>
Code: Select all
...
accordionIndex: number[ ] = [-1];
...
onCancel() {
this.accordionIndex = [0,3];
}