[英]Get step index from Angular Material Design Stepper
我正在尝试在使用 Angular Material Design 步进器的组件中获取选定的步骤。
问题是我试图通过使用 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);
}
我期望步进器的选定索引,但我总是检索“1”
尝试将stepControl
显式stepControl
为您的matStep
。 例如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.