我使用此验证规则:
this.addVisitorForm = this.fb.group({company: [null, []]});
如您所见,字段没有验证 company . 但是角说它是无效的,怎么做这个场就没有必要了?
company
HTML代码是:
<input maxlength="25" [ngClass]="{ 'has-error': addVisitorForm.get('company').invalid }"formControlName="company" type="text" class="form-control form-control-lg" required>
你把 HTML 5 验证和 reactive form 验证。移除 required 属性来自 <input> 标签
HTML 5
reactive form
required
<input>
<input maxlength="25" [ngClass]="{ 'has-error': addVisitorForm.get('company').invalid }"formControlName="company" type="text" class="form-control form-control-lg">