This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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
Closed
Description
The thing goes like this:
- 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.
To my knowledge this wasn't happening in 1.2.x.