填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫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>