如何通过表单控件验证具有输入类型=时间字段?二手角材料

问题描述 投票:0回答:2

与输入类型=时间字段不能经由形式控制验证。我得到的错误:

Error错误:没有价值的存取与名称表单控件:“thirdCtrl”

的代码,不通过验证处理部分

 <mat-step [stepControl]="thirdFormGroup">
    <form [formGroup]="thirdFormGroup">    
<mat-form-field formControlName="thirdCtrl">
    <input matInput type="time">
    </mat-form-field>
      <button mat-button matStepperNext>Next</button>
    </form>
  </mat-step>

简单FormGroup以上形式

this.thirdFormGroup = this._formBuilder.group({
      thirdCtrl: ['', Validators.required]
    });

我怀疑,因为FormControl尝试处理输入字段类型时错误,但我不知道如何改变这个FormControl我的情况。

angular forms angular-material
2个回答
2
投票

尝试移动formControlName="thirdCtrl"<mat-form-field>结合<input>,如:

<mat-step [stepControl]="thirdFormGroup">
    <form [formGroup]="thirdFormGroup">    
       <mat-form-field>
          <input matInput type="time" formControlName="thirdCtrl">
       </mat-form-field>
      <button mat-button matStepperNext>Next</button>
    </form>
</mat-step>

1
投票
<mat-step [stepControl]="thirdFormGroup">
    <form [formGroup]="thirdFormGroup">    
<mat-form-field>
    <input matInput type="time" formControlName="thirdCtrl">
    </mat-form-field>
      <button mat-button matStepperNext>Next</button>
    </form>
  </mat-step>
© www.soinside.com 2019 - 2024. All rights reserved.