When I add a new element in an accordion I would like to
- add the new element
- close all tabs
I use the activeIndex property
Here is my code :
- template :
Code: Select all
<p-accordion [multiple]="true" [activeIndex]="activeTab" >
<p-accordionTab *ngFor="let elt of data">
...
</p-accordionTab>
</p-accordion>
Code: Select all
activeTab = []; // declaration
Code: Select all
onAdd()
{
const newElt = ...;
this.data.unshift(newElt);
this.activeTab.length = 0; // close all tabs
}
NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
I probably misuse this component. What is wrong in my code ?