本文介绍了MatHorizo​​ntalStepper stepControl具有模板驱动的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将[stepControl]错误匹配器与模板驱动的表单一起使用?这些文档只是讲授了一个AbstractControl实例,该实例显然强制使用了reactForm.

Is there any way to use [stepControl] error matcher with template driven forms? The docs just teach about an AbstractControl instance, which apparently forces the use of a reactiveForm.

我尝试使用[stepControl]="myNgForm"[linear]="true"来验证步骤,但步进器只会忽略它.

I've tried to use [stepControl]="myNgForm" and [linear]="true" to validate the steps but the stepper just ignores it.

感谢您的帮助.

谢谢!

推荐答案

步骤控件似乎可以与"form.control"一起使用.这是一个示例,其中每个步骤一个表单和模板驱动的表单.

The step control seems to work with "form.control".Here an example with one form per step and template driven forms.

  <mat-vertical-stepper [linear]="true">
    <mat-step [stepControl]="form1.control">
       <form #form1="ngForm">
          <input [(ngModel)]="name" name="name" required />
       </form>
    </mat-step>
    <mat-step [stepControl]="form2.control">
       <form #form2="ngForm">
          <input [(ngModel)]="address" name="address" required />
       </form>
    </mat-step>
  </mat-vertical-stepper>

这篇关于MatHorizo​​ntalStepper stepControl具有模板驱动的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 19:08