Can't select item in md-radio-group with *ngFor and changing content
See original GitHub issueBug, feature request, or proposal:
Bug 😃
What is the expected behavior?
Even if the list of items in the *ngFor
are updated (e.g. cloned), clicking on an md-radio-button
should still make it “selected”
What is the current behavior?
If I provide some list of items to an *ngFor
, but the items are different instances on each angular tick, I should still be able to select the associated md-radio-button
s for those items. For example:
// ...
get fish() {
return [
{name: 'Bob'},
{name: 'Amir'},
{name: 'Toyin'}
]
}
// ...
-----
<md-radio-button *ngFor="let f of fish" [value]="f.name">{{f.name}}</md-radio-button>
With the current behaviour, I can’t select any of the items in this list of fish 😃
What are the steps to reproduce?
http://plnkr.co/edit/0sX0rzMZdOHyP7NSLPkk?p=info
What is the use-case or motivation for changing an existing behavior?
In cases where such a list is queried from an external source (like a server), it would be a shame if the “currently-selected item state” was lost - even if the data was identical! - because the data is now different “instances”
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4, Chrome 62
Is there anything else we should know?
Thanks for the useful, stylish components!
This may be mildly similar to #1862
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Talked to my buddy @hneiva, I can use
trackBy
in*ngFor
to avoid the digest recreating the DOM elements. I’ve made a new plunker to show the working solution, but plunker is currently error-ing out, so I can’t be sure that it’s actually running correctly.Thanks Jeremy for the assistance, hopefully this is enough explanation to clear up any confusion 😃
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.