Setting Initial Validity and Active Step in Angular Material Stepper Based on Form Validity

57 views Asked by At

How can I set the validity of Angular Material Stepper steps to 'valid' initially if the associated forms are already valid upon the initial page load? Here's the code snippet for reference:

<mat-stepper orientation="vertical" linear [selectedIndex]="activeStep">
<mat-step [stepControl]="form1">
<!-- ... -->
</mat-step>
<mat-step [stepControl]="form2">
    <div #formContainer></div>
</mat-step>
<mat-step [stepControl]="form3">
<!-- ... --
</mat-step>

In the scenario where form1 and form2 are valid upon initialization, I want both step1 and step2 to be set as valid, and initially, step3 should be the active step.

0

There are 0 answers