我正在尝试在表单验证后继续处理子组件。
我可以使用matStepperNext
进行下一步,但无需验证即可使用。
我尝试使用以下方法,但是stepper
未定义
子组件:
@ViewChild('stepper', { static: true }) stepper: MatStepper;
...some code
if (formValid){
this.stepper.next()
}
父组件HTML:
<mat-horizontal-stepper #stepper [linear]="true">
<mat-step [stepControl]="form1">
<ng-template matStepLabel>Form 1</ng-template>
<app-child1></app-child1>
</mat-step>
<mat-step [stepControl]="form2">
<ng-template matStepLabel>Form 1</ng-template>
<app-child2></app-child2>
</mat-step>
<mat-step [stepControl]="form3">
<ng-template matStepLabel>Form 3</ng-template>
<app-child3></app-child3>
</mat-step>
</mat-horizontal-stepper>