Since Angular 5 release, I have some problem with my mat expansion panels. They are opened by default and I don't understand why.
my html
<div *ngFor="let block of blocks; let i = index;">
<mat-expansion-panel *ngIf="selectedIndex == 2" (closed)="onClosed(i)" (opened)="onOpened(i)" [expanded]="expansionPanelIndex === i">
<mat-expansion-panel-header>
<mat-panel-title>
....
</mat-panel-title>
<mat-panel-description>
...
</mat-panel-description>
</mat-expansion-panel-header>
</mat-expansion-panel>
</div>
in my component
tabChanged(tabChangeEvent: MatTabChangeEvent): void {
this.selectedIndex = tabChangeEvent.index;
}
onOpened(i) {
this.expansionPanelIndex = i;
}
onClosed(i) {
this.expansionPanelIndex = -1;
}
EDIT : I updated Material to 5.1.1 same problem EDIT 2 : I had a "selectedTabIndex" in my tab-group
<mat-tab-group [(selectedIndex)]="selectedIndex" (selectedTabChange)="tabChanged($event)">
...
<mat-expansion-panel ...>
</mat-expansion-panel>
</mat-tab-group>
The two way binding wasn't a good idea here. But now, I have another problem (click on nextStep button doesn't do anything)
expansionPanelIndex
for? Is it, because you want not more than one panel to be opened at a time? – Kim Kern