填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

CheckboxRequiredValidator

該指令會藉助 NG_VALIDATORS 繫結把 required 驗證器新增到任何帶有 required 屬性的檢查框控制元件上。

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

參見

Exported from

選擇器

  • input[type=checkbox][required][formControlName]
  • input[type=checkbox][required][formControl]
  • input[type=checkbox][required][ngModel]

繼承自 RequiredValidator

說明

使用範本驅動表單為複選框新增必填項驗證器

Adding a required checkbox validator using template-driven forms

下面的例子展示了如何為一個帶有 ngModel 繫結的檢查框新增必填項驗證器。

The following example shows how to add a checkbox required validator to an input attached to an* ngModel binding.

      
      <input type="checkbox" name="active" ngModel required>