- directive in module ng
ngMaxlength adds the maxlength validator
to ngModel
. It is most often used for text-based input
controls, but can also be applied to custom text-based controls.
The validator sets the maxlength
error key if the ngModel.$viewValue
is longer than the integer obtained by evaluating the Angular expression given in the ngMaxlength
attribute value.
Note: This directive is also added when the plain
maxlength
attribute is used, with two differences: -
ngMaxlength
does not set themaxlength
attribute and therefore HTML5 constraint validation is not available. - The
ngMaxlength
attribute must be an expression, while themaxlength
value must be interpolated.
Directive Info
- This directive executes at priority level 0.
Usage
- as attribute:
<ANY> ... </ANY>
Please login to continue.