I currently have a directive that I am placing on an <input>
element that will format the text to uppercase, currency, ...etc. as the user types. This all works great by implementing ControlValueAccessor, but the control validity state is not updating after the writeValue
method executes.
Is there a way to force the FormControl
in the ngModel on the input to validate, or is there a way to inject the NgModel
/FormControl
instance into a directive that is placed on the same input? Whenever I try to inject it I get a cyclic dependency error. I'm trying to use the updateValueAndValidity()
method on the control property of the NgModel
instance to update the state, but this could be wrong as well.
If there is also a better way to approach this then I'm open to suggestions as well. Basically trying to translate a directive from Angular 1.x that used $formatters
and $parsers
and required the ngModel
instance...
Let me know if you would like to see snippets of code for anything specific.