MatHorizo​​ntalStepper stepControl 带有模板驱动的表单 [英] MatHorizontalStepper stepControl with template driven forms

查看:14
本文介绍了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 带有模板驱动的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆