I am trying to get the selected step in an component that is using Angular Material Design stepper.
The thing is that I am trying to get it by using selectedIndex property, but now is always getting "1" when I try to get it
<button mat-button mat-flat-button color="primary"
(click)="onSave(stepper)">
SAVE
</button>
onSave(stepper: MatStepper)
{
debugger;
let workflowStepName = this.declarationWorkflowHelper.getWorkflowName(stepper.selectedIndex);
this.screenSave.next(workflowStepName);
}
I expect the selected index of the stepper, but I am always retrieving "1"
Try to set explicitly stepControl
to your matStep
. Eg firstFormGroup
, secondFormGroup
:
<mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<!-- The code is omitted for the brevity -->
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step [stepControl]="secondFormGroup">
<form [formGroup]="secondFormGroup">
<!-- The code is omitted for the brevity -->
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.