@version angularjs 1.6.2
I'm trying to do some formatters and parsers to have generic input/output for my really huge project.
The use case :
I have a custom component with ngModelController required on it, but when I use this component in my view with an attribute directive; which also requires ngModel to add $parser or $formatters; but when the value is changing into the component the $formatters or $parsers assign on it aren't called.
Te logic I would like
Component : ArtistSelect
Directive (parser) : ngObject ng-object-formatter="attribute_object" ng-object-parser="attribute_object"
View :
<artist-select ng-model="model.artist" ng-object ng-object-formatter="id_artist"></artist-select>
I would like the model.artist being formatted like : {id_artist: integer} instead of only an integer.
Angular doc : Note that the $parsers are not called when the bound ngModel expression changes programmatically.
also
Angular Doc : Since ng-model does not do a deep watch, $render() is only invoked if the values of $modelValue and $viewValue are actually different from their previous values. If $modelValue or $viewValue are objects (rather than a string or number) then $render() will not be invoked if you only change a property on the objects.
How to make it work ?
WORKING PLUNKER : Behavior
Maybe I'm missing something, maybe I'm overthinking the the things or maybe It's just not possible to do.
Your help will be really appreciated !