You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to bind objects to radio button values and need an own function for comparing the ngModel with the value.
Describe the solution you'd like
I suggest the RadioControlValueAccessor should have compareWith like the SelectControlValueAccessor.
Describe alternatives you've considered
Reacted by adam-marshall, Paul Lunt, Taylor Mills, David Gilson, JB Nizet, zaggi, vitalii-baziuk-simpligov, Ken Southerland, Ricardo Cárdenas Guevara, Stefan Kienzle and 3 more
@kara If I provide an object as my [(ngModel)] and want to have the radio button's [value] to be an object too, the radio button directive never marks the radio as checked, since it compares by strict equality.
If this lines could be copied to the radio_control_value_accessor.ts and writeValue could be changed to the following, it would be easy to implement a custom function to check the identity.
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.
@JeanMeche this can be closed. freq1: low and feature: under consideration since 2019 with no duplicate reports, and adding an input to RadioControlValueAccessor is new public API in a package that is only being maintained.
There is also an existing route: identity comparison works if the bound object is the same instance, which is the normal pattern for radio groups over a fixed option list.
Signal forms is where value comparison and transforms get a design, so raising the use case there is more likely to go somewhere.
Activity
kara commentedon Feb 5, 2019
@sclausen can you add some more detail to this? suggested use, etc
sclausen commentedon Feb 7, 2019
@kara If I provide an object as my
[(ngModel)]and want to have the radio button's[value]to be an object too, the radio button directive never marks the radio as checked, since it compares by strict equality.If this lines could be copied to the
radio_control_value_accessor.tsandwriteValuecould be changed to the following, it would be easy to implement a custom function to check the identity.I would've provided a PR, but don't know how to write a test case for this.
adam-marshall commentedon Sep 23, 2019
I need this too. I am using
[compareWith]for select controls, but there is no equivalent way of getting this to work with radio buttons.The justification is the same as the following issues, but for radio buttons instead of select:
#13268 (comment)
#13295
#12742
https://stackoverflow.com/questions/40325480/angular2-ngmodel-ngvalue-select-option-object-equality-across-different-instan
Therefore it would probably be intuitive for
radio_control_value_accessor.tsto use the same pattern?adam-marshall commentedon Nov 21, 2019
There is a related issue on material which this would resolve too: angular/components#10495
angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 24, 2021
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.
Kienz commentedon Jun 25, 2024
Is this planned for future releases?
arturovt commentedon Sep 29, 2026
@JeanMeche this can be closed. freq1: low and feature: under consideration since 2019 with no duplicate reports, and adding an input to RadioControlValueAccessor is new public API in a package that is only being maintained.
There is also an existing route: identity comparison works if the bound object is the same instance, which is the normal pattern for radio groups over a fixed option list.
Signal forms is where value comparison and transforms get a design, so raising the use case there is more likely to go somewhere.