从角材料设计步进处获取步骤索引



我正在尝试将所选的步骤中的组件中的所选步骤获取,该组件使用角材料设计步进。

问题是我试图通过使用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明确设置为matStep。例如。firstFormGroupsecondFormGroup

<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>

最新更新