Provide ControlValueAccessors for libraries other than @angular/forms
See original GitHub issue🚀 feature request
Relevant Package
This feature request is for @angular/forms
Description
The infrastructure surrounding ControlValueAccessor
is widely adopted by component libraries, but currently the built-in ones are hardcoded to only be provided for ngModel
, formControl
and formControlName
, preventing external libraries from benefiting from the existing implementations when implementing a new directive which wants to make use of the accessors.
Describe the solution you’d like
I would like to be able to have some way to also provide these accessors when my own directive is present (instead of ngModel, formControl, formControlName). I don’t have a concrete suggestion of what that would look like.
Describe alternatives you’ve considered
A workaround is to tell users to add ngModel
as well, but this is not only awkward, it also interferes as now the entire forms infrastructure kicks in and calls writeValue
on its own etc.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10 (9 by maintainers)
I tried that, but it doesn’t work that well and it’s a complete hack. Not to mention you still need to have a copy of all accessor classes anyway (and not all accessors are currently exported).
It would be much easier if libraries didn’t have to worry about any of this. Combined with the ability to create directives from directives (which is another feature request), we could then even get rid of having users add both directives.
Thank you for submitting your feature request! Looks like during the polling process it didn’t collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular’s scope, we’d encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.