material icon indicating copy to clipboard operation
material copied to clipboard

radio-group: Default Object Value problem

Open matraned opened this issue 9 years ago • 5 comments

Actual Behavior:

I have a problem setting a default object value on a md-radio-group.

CodePen (or steps to reproduce the issue): *

https://codepen.io/matraned/pen/GmYZRm

AngularJS Versions: *

Angular v1.5.8 Materials v1.1.1


Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

matraned avatar May 20 '17 21:05 matraned

You would think your issue would be solved by adding track by met.idMetodo to your ng-repeat, but alas. The problem is that the render function of mdRadioButtonDirective compares object references and does not take the track by information into account. md-select does this via ng-model-options="{trackBy: xyz}".

This plunkr illustrates the issue further: https://embed.plnkr.co/YpIclp3dBypvILTvq1Fh/

The expected result in the plunkr is that the correct radio button (2) should be selected on load.

sviams avatar Jun 30 '17 09:06 sviams

+1

leonelthiesen avatar Aug 16 '17 13:08 leonelthiesen

Has anything come from this bug? I am having the same problem that @sviams has exampled.

holtjonathan avatar Dec 13 '17 18:12 holtjonathan

+1

wilker7ribeiro avatar Dec 27 '17 13:12 wilker7ribeiro

This is a duplicate of https://github.com/angular/material/issues/6225. We would welcome a PR to add trackBy support to md-radio-group.

Splaktar avatar Mar 27 '18 08:03 Splaktar