@@ -42,9 +42,14 @@ var inputType = {
42
42
* minlength.
43
43
* @param {number= } ngMaxlength Sets `maxlength` validation error key if the value is longer than
44
44
* maxlength.
45
- * @param {string= } ngPattern Sets `pattern` validation error key if the value does not match the
46
- * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
47
- * patterns defined as scope expressions.
45
+ * @param {string= } pattern Similar to `ngPattern` except that the attribute value is the actual string
46
+ * that contains the regular expression body that will be converted to a regular expression
47
+ * as in the ngPattern directive.
48
+ * @param {string= } ngPattern Sets `pattern` validation error key if the ngModel value does not match
49
+ * a RegExp found by evaluating the Angular expression given in the attribute value.
50
+ * If the expression evaluates to a RegExp object then this is used directly.
51
+ * If the expression is a string then it will be converted to a RegExp after wrapping it in `^` and `$`
52
+ * characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
48
53
* @param {string= } ngChange Angular expression to be executed when input changes due to user
49
54
* interaction with the input element.
50
55
* @param {boolean= } [ngTrim=true] If set to false Angular will not automatically trim the input.
@@ -585,9 +590,14 @@ var inputType = {
585
590
* minlength.
586
591
* @param {number= } ngMaxlength Sets `maxlength` validation error key if the value is longer than
587
592
* maxlength.
588
- * @param {string= } ngPattern Sets `pattern` validation error key if the value does not match the
589
- * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
590
- * patterns defined as scope expressions.
593
+ * @param {string= } pattern Similar to `ngPattern` except that the attribute value is the actual string
594
+ * that contains the regular expression body that will be converted to a regular expression
595
+ * as in the ngPattern directive.
596
+ * @param {string= } ngPattern Sets `pattern` validation error key if the ngModel value does not match
597
+ * a RegExp found by evaluating the Angular expression given in the attribute value.
598
+ * If the expression evaluates to a RegExp object then this is used directly.
599
+ * If the expression is a string then it will be converted to a RegExp after wrapping it in `^` and `$`
600
+ * characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
591
601
* @param {string= } ngChange Angular expression to be executed when input changes due to user
592
602
* interaction with the input element.
593
603
*
@@ -667,9 +677,14 @@ var inputType = {
667
677
* minlength.
668
678
* @param {number= } ngMaxlength Sets `maxlength` validation error key if the value is longer than
669
679
* maxlength.
670
- * @param {string= } ngPattern Sets `pattern` validation error key if the value does not match the
671
- * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
672
- * patterns defined as scope expressions.
680
+ * @param {string= } pattern Similar to `ngPattern` except that the attribute value is the actual string
681
+ * that contains the regular expression body that will be converted to a regular expression
682
+ * as in the ngPattern directive.
683
+ * @param {string= } ngPattern Sets `pattern` validation error key if the ngModel value does not match
684
+ * a RegExp found by evaluating the Angular expression given in the attribute value.
685
+ * If the expression evaluates to a RegExp object then this is used directly.
686
+ * If the expression is a string then it will be converted to a RegExp after wrapping it in `^` and `$`
687
+ * characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
673
688
* @param {string= } ngChange Angular expression to be executed when input changes due to user
674
689
* interaction with the input element.
675
690
*
@@ -750,9 +765,14 @@ var inputType = {
750
765
* minlength.
751
766
* @param {number= } ngMaxlength Sets `maxlength` validation error key if the value is longer than
752
767
* maxlength.
753
- * @param {string= } ngPattern Sets `pattern` validation error key if the value does not match the
754
- * RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
755
- * patterns defined as scope expressions.
768
+ * @param {string= } pattern Similar to `ngPattern` except that the attribute value is the actual string
769
+ * that contains the regular expression body that will be converted to a regular expression
770
+ * as in the ngPattern directive.
771
+ * @param {string= } ngPattern Sets `pattern` validation error key if the ngModel value does not match
772
+ * a RegExp found by evaluating the Angular expression given in the attribute value.
773
+ * If the expression evaluates to a RegExp object then this is used directly.
774
+ * If the expression is a string then it will be converted to a RegExp after wrapping it in `^` and `$`
775
+ * characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
756
776
* @param {string= } ngChange Angular expression to be executed when input changes due to user
757
777
* interaction with the input element.
758
778
*
@@ -2582,7 +2602,7 @@ var patternDirective = function() {
2582
2602
var regexp , patternExp = attr . ngPattern || attr . pattern ;
2583
2603
attr . $observe ( 'pattern' , function ( regex ) {
2584
2604
if ( isString ( regex ) && regex . length > 0 ) {
2585
- regex = new RegExp ( regex ) ;
2605
+ regex = new RegExp ( '^' + regex + '$' ) ;
2586
2606
}
2587
2607
2588
2608
if ( regex && ! regex . test ) {
0 commit comments