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.

MdSelect not properly providing NG_VALUE_ACCESSOR

See original GitHub issue

Bug:

The MdSelect component implements the ControlValueAccessor interface but does not export itself as an NG_VALUE_ACCESSOR.

What is the expected behavior?

MdSelect should contain a provider for NG_VALUE_ACCESSOR (like MdCheckbox already does correctly), i.e. add the following:

export const MD_SELECT_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => MdSelect),
  multi: true,
};

and then add this to the @Component annotation:

  providers: [MD_SELECT_CONTROL_VALUE_ACCESSOR],

In addition, it should not assign itself to the valueAccessor property of the injected control, but leave that to the @angular/forms infrastructure.

What is the use-case or motivation for changing an existing behavior?

Currently, the MdSelect component only works with @angular/forms and not with any other “form-like” library that requires access to the NG_VALUE_ACCESSOR (in my case I am trying to write a forms library for ngrx in which I completely sidestep everything from @angular/forms except the ControlValueAccessor mechanism.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Current master of material2.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
karacommented, Aug 23, 2017

This is a legitimate pattern for setting custom value accessors that is necessary to gain access to the control (which in turn is necessary to support our current feature set). It’s not possible to both inject the control and provide the class as an accessor. As changing this would introduce regressions in the select, closing.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 10, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error not showing for Angular Material md-select
I'm trying to implement a form where the error messages don't show up until the submit button is clicked. For an input, this...
Read more >
Directives > mdSelect - AngularJS Material
Parameter Type Description * ng‑model expression expression Assignable angular expression to data‑bind to. placeholder string string Placeholder hint text.
Read more >
angular material 2 custom component with ng value accessor ...
How do I set default value on md-select component from angular 2 material design? ... How to fix 'Error: No value accessor for...
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