The validator sets the
pattern error key if the
ngModel.$viewValue does not match a RegExp which is obtained from the
ngPattern attribute value:
$characters. For instance,
"abc"will be converted to
ngPattern="/^\d+$/", it is used directly.
gflag on the RegExp, as it will cause each successive search to start at the index of the last search's match, thus not taking the whole input value into account.
patternattribute is used, with two differences:
ngPatterndoes not set the
patternattribute and therefore HTML5 constraint validation is not available.
ngPatternattribute must be an expression, while the
patternvalue must be interpolated.
<ANY ng-pattern=""> ... </ANY>
|ngPattern|| || |
AngularJS expression that must evaluate to a
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.