Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio button group pre selection does not work #341

Open
OliverHi opened this issue Aug 9, 2018 · 1 comment
Open

Radio button group pre selection does not work #341

OliverHi opened this issue Aug 9, 2018 · 1 comment

Comments

@OliverHi
Copy link

OliverHi commented Aug 9, 2018

Expected Behavior

A radio button group that has ngModel connected to it should be able to (pre)select the right radio button that corresponds to the model. Even if the selected part of the model is an object

Current Behavior

Currently no selection is made. I had similar issues with selects that seem to happen because of the linked model beeing (complex) objects. Implementing a custom [compareWith]=... helped there (by simply comparing ids). Otherwise only object reference seems to be compared. Radio buttons do not seem to have a similar attribute so this did not work here.

Possible Solution

Maybe add a custom way to compare for radio buttons?

Steps to Reproduce (for bugs)

  1. Create radiobuttons with *ngFor based on an array of objects
  2. Fill the "target" model, the one linked to the radio button via ngModel, with an exact copy of an object from the array (but not the same object, just a copy)
  3. None of the radio buttons gets selected

Here is a stackblitz demonstrating the problem.

Context

I am trying to display a form for a user to change existing data. Some of that should be displayed as a radio group where the selection from last time gets preselected on reopening.
The possible values for the radio buttons and the users selection get loaded seperately from a server. That is why they contain the same object (content wise) but have different object references, which seems to confuse ngx-materialize's radiobuttons.
Ignoring this problem I loved the library until now, so a fix or workaround for this would be great!

Your Environment

  • Version used: 6.1.1 (via npm)
  • Angular version used: 6
  • Browser Name and version: tested with chrome and firefox
  • Operating System and version (desktop or mobile): windows 10 desktop

If more information is needed I will try to provide that.

@OliverHi
Copy link
Author

PS updated stackblitz and text to describe the problem better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant