I have a problem since Angular 5.X with a form-wizard (mat-tab-group). Everything woks fine by using clicks on tabs, it switchs between tabs but I can't use a "nextStep" or "previousStep" buttons to switch between tabs. Here my code :
component.html
<mat-tab-group [(selectedIndex)]="selectedIndex" (selectedTabChange)="tabChanged($event)" class="mat-tab-group mat-primary">
<mat-tab label="Description">
content...
<mat-card-content class="mat-card-content">
</mat-card-content>
<mat-card-footer style="margin:0 auto;">
<div fxLayout="row" fxLayoutAlign="end center">
<button mat-button type="button" (click)="cancel()" mat-raised-button color="warn">Cancel</button>
<button color="primary" mat-raised-button (click)="nextStep()" type="button">Next</button>
</div>
</mat-card-footer>
</mat-tab>
</mat-tab-group>
component.ts
public tabChanged(tabChangeEvent: MatTabChangeEvent): void {
this.selectedIndex = tabChangeEvent.index;
}
public nextStep() {
this.selectedIndex += 1;
}
public previousStep() {
this.selectedIndex -= 1;
}
I'm stuck with [(selectedIndex)]="selectedIndex" because it doesn't work with mat-expansion-panel (Mat expansion panel is opened by default bug?). So I have to remove it but, if i remove it my buttons "nextStep" and "previousNext" doesn't work anymore...
I'm using : Angular material 5.1.1
Any idea about this ?
EDIT : As I said, the problem was about the selectedIndex... I used the selectedIndex in a condition to display the mat-expansion-panel. Bad idea... so solve the problem, I've created a boolean in my component to display or not the mat-expansion-panel. If i'm on the good tab, I set the boolean to true else, the boolean is false. Hope it's clear ^^