-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$setViewValue makes invalid field blank if using attribute «pattern» #9986
Comments
Well, using ng-pattern is a bad idea — it accepts only valid regexps. Now I use a directive name as attribute:
|
e: I see, you already changed the attribute name. |
tbh honest I am not really sure why $setViewValue would empty the whole input. Can you provide a minimal example if this happening? |
Plunker — http://plnkr.co/edit/54otaclvjjZUW63vR9QT?p=preview — just try to enter some letters a-z and then some digits in first input (with directive «broken-input»). |
Thanks for the plnkr. This is a dupe of #9156 |
The problem is that the |
Thank you! And thanks for explaining all this $render stuff :) |
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: