我正在尝试获取使用Angular Material Design stepper的组件中的选定步骤。
问题是,我试图通过使用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“。
发布于 2019-06-27 22:06:05
尝试将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>https://stackoverflow.com/questions/56792512
复制相似问题