[英]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.