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 was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ctrl.$validate(); and custom formatters do not play well toghether in 1.3.x and can lead to side effects #10025
I have a directive with a custom formatter (a custom datetime control) that alters the value in the model in some way for display purposes (datetime object formatted using a mask, something like: dd/mm/yyyy hh:mm, you will of course loose precision)
so you have: $modelValue with the original datetime (precision up to milliseconds) and $viewValue with the modified value (precision up to minutes).
if you place any directive/attribute that internally invoke ctrl.$validate() (like the ngRequired) this will have the side effect of parsing the value again and ASSIGN it to the model, OVERWRITING the original value even if the user didn't typed or interacted with anything.
Personally I do think this kind of side-effects are dangerous, something that does a validation should not change my model value.
Activity
Narretz commentedon Nov 12, 2014
I answered you comment in the other thread; can you please provide a reproduction of this issue? It seem to differ slightly from the other issues.
AGiorgetti commentedon Nov 12, 2014
Hi, here's a plunker that reproduce my issue:
http://plnkr.co/edit/xUppA8
you can switch to angular 1.2.x and see that the side effect is not there.
have fun :)
fix(ngModel): don't run parsers when executing $validate
fix(ngModel): don't run parsers when executing $validate
fix(ngModel): don't run parsers when executing $validate
fix(ngModel): don't run parsers when executing $validate
fix(ngModel): don't run parsers when executing $validate
fix(ngModel): don't run parsers when executing $validate
Narretz commentedon Nov 25, 2014
This is fixed in 1.3.4 :)