question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Airbladercommented, Dec 15, 2018

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.

0reactions
angular-robot[bot]commented, Jun 14, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ControlValueAccessor
This method is called by the forms API to write to the view when programmatic changes from model to view are requested.
Read more >
Never again be confused when implementing ...
Since Angular provides control value accessors for all default native controls a new value accessor is most often implemented to wrap 3rd party...
Read more >
Angular Reactive Forms - Control Value Accessor
CVA is a bridge between the Angular forms API and a native element in the DOM, like making a component compatible with Reactive...
Read more >
Creating custom form controls in Angular (Control Value ...
This video covers Control Value Accessors, and how we can use them to minimise boilerplate markup in our forms.
Read more >
No value accessor for form control with unspecified name ...
Only if you have "Angular Material" installed, otherwise you don't need this. – Mikefox2k. May 18, 2020 at 7:23. 2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found