You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
There I have two input fields and two directives — the only difference in this fields and directives is that one has «pattern="a-z"» attribute and other has «blabla="a-z"» attribute.
The one with «pattern» attribute doesn't work — $setViewValue() makes it blank if it does not fit the pattern regexp.
So, what is the problem with this «pattern» attribute — why does it brake everything? Does Angular use both «pattern» and «ng-pattern» attribute to validate input field? Why «pattern» attribute makes field blank if it is not valid?
Also, I have changed «pattern» to «ng-pattern» and it resolved the problem:
<input type="text" name="foo" ng-pattern="a-z" ng-model="user.foo" working-input>
and in directive:
var pattern = attributes.ngPattern;
I'm creating this issue for those who has the same problem and spend about 30 minutes to resolve it (because renaming «pattern» attribute to something else really is not obvious).
(I have found some issues here but they all are about $asyncValidators)
The text was updated successfully, but these errors were encountered:
pattern is recognized by angular as a directive and processed as such. There's currently a difference between the attributes: pattern takes the regex as a simple string, ng-pattern takes it as a regex ' object'. So in both cases, you will run into problems if you use the attribute for you own uses. Can't you use a different attribute name?
The problem is that the $render function for ngModelController now explicitly forbids rendering when the modelValue is empty, which doesn't make sense. Until this is fixed, you can overwrite the $render function with something like what this PR implements: #9681
Plunker — http://plnkr.co/edit/54otaclvjjZUW63vR9QT?p=preview
There I have two input fields and two directives — the only difference in this fields and directives is that one has «pattern="a-z"» attribute and other has «blabla="a-z"» attribute.
The one with «pattern» attribute doesn't work — $setViewValue() makes it blank if it does not fit the pattern regexp.
So, what is the problem with this «pattern» attribute — why does it brake everything? Does Angular use both «pattern» and «ng-pattern» attribute to validate input field? Why «pattern» attribute makes field blank if it is not valid?
Also, I have changed «pattern» to «ng-pattern» and it resolved the problem:
I'm creating this issue for those who has the same problem and spend about 30 minutes to resolve it (because renaming «pattern» attribute to something else really is not obvious).
(I have found some issues here but they all are about $asyncValidators)
The text was updated successfully, but these errors were encountered: