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

MaxLengthValidator

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

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

參見

Exported from

選擇器

屬性

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

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

Tracks changes to the maximum length bound to this directive.

說明

新增最大長度驗證器

Adding a maximum length validator

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

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

      
      <input name="firstName" ngModel maxlength="25">