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

MinLengthValidator

該指令用於為帶有 minlength 屬性的控制元件新增最小長度驗證器。該指令會提供 NG_VALIDATORS 多重提供者列表。

A directive that adds minimum length validation to controls marked with the minlength attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

參見

Exported from

選擇器

屬性

屬性說明
@Input()
minlength: string | number

追蹤與此指令繫結的最小長度的更改。

Tracks changes to the minimum length bound to this directive.

說明

新增最小長度驗證器

Adding a minimum length validator

下面的例子示範瞭如何為帶有 ngModel 繫結的輸入框新增最小長度驗證器。

The following example shows how to add a minimum length validator to an input attached to an ngModel binding.

      
      <input name="firstName" ngModel minlength="4">