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
mult-provider list.
参见
NgModules
选择器
[minlength][formControlName]
[minlength][formControl]
[minlength][ngModel]
属性
属性 | 说明 |
---|---|
@Input() | Tracks changes to the 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">
方法
A lifecycle method called when the directive's inputs change. For internal use only. | |||
参数
返回值
|
Method that validates whether the value meets a minimum length requirement. Returns the validation result if enabled, otherwise null. | |||
参数
返回值
|
Registers a callback function to call when the validator inputs change. |