MdSelect not properly providing NG_VALUE_ACCESSOR
See original GitHub issueBug:
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:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top GitHub Comments
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.
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.