填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

RequiredValidator

该指令会借助 NG_VALIDATORS 绑定把 required 验证器添加到任何带 required 属性的控件上。

A directive that adds the required validator to any controls marked with the required attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

参见

Exported from

选择器

  • :not([type=checkbox])[required][formControlName]
  • :not([type=checkbox])[required][formControl]
  • :not([type=checkbox])[required][ngModel]

属性

属性说明
@Input()
required: boolean | string

跟踪对该指令绑定的 required 属性的更改。

Tracks changes to the required attribute bound to this directive.

说明

使用模板驱动表单添加必填项验证器

Adding a required validator using template-driven forms

      
      <input name="fullName" ngModel required>