mat-radio-group data binding does not work when parent component is repeated
Bug, feature request, or proposal:
Fix mat-radio-group data binding so it works when parent component is repeated.
What is the expected behavior?
mat-radio-group data binding should work when parent component is repeated.
What is the current behavior?
mat-radio-group data binding does not work when parent component is repeated.
What are the steps to reproduce?
See that both mat-radio-group and the standard html radio inputs are bound to the same property, yet the mat-radio-group data binding only works in the 3rd instance of the parent component.
https://stackblitz.com/edit/angular-gt2qqc
What is the use-case or motivation for changing an existing behavior?
I need to be able to repeat the parent component of mat-radio-group.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5.2.5 Material 5.2.1 Windows 10 Pro TypeScript 2.6.2 Chrome 64.0.3282.167
Is there anything else we should know?
@josephperrott, the other issues about this were closed (the second one because of wrong formatting), but it looks like he has an important point. Considering the fact he is using separate form tags (the <form> tags are inside a custom component), something weird is happening - ngModel seems to become confused.
I have also run into this same issue
FWIW, the workaround is to ensure that the mat-radio-group name is unique across all instances of the custom component.
I think I misunderstood the previously opened issue about it.
This is working as intended. mat-radio-button will uncheck all radio buttons with the same name when a radio button is clicked.
Each radio group should have its own unique name. If you remove the name="radioTypeA" on mat-radio-group, radio group will automatically generate a unique name.
Seems like a weird decision to make it less functional than a standard html radio input, but ok I guess.
@kwall2004, @tinayuangao, there's another issue tracking this behavior. It looks like it's not normal the uniqueness of the name bleeding to the outside of a form tag.
The other issue: #5983
I think we can definitively say it's not normal.
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.