[英]Get step index from Angular Material Design Stepper
I am trying to get the selected step in an component that is using Angular Material Design stepper.我正在尝试在使用 Angular Material Design 步进器的组件中获取选定的步骤。
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问题是我试图通过使用 selectedIndex 属性来获取它,但是现在当我尝试获取它时总是得到“1”
<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"我期望步进器的选定索引,但我总是检索“1”
Try to set explicitly stepControl
to your matStep
.尝试将
stepControl
显式stepControl
为您的matStep
。 Eg firstFormGroup
, secondFormGroup
:例如
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.