MrWolfZ/ngrx-forms

mat-radio checked not working?

work79 opened this issue · 1 comments

Hello, I need to set radio-button value from the state. I tried having just [ngrxFormControlState], but the problem is that the state is set from loaded data, so the values are in the state, but the radio-buttons are not checked. Components such as mat-select works normally.

So far I have the following (it is important to note that without ngrxFormControlState they are checked, but you cannot control the state):

<mat-radio-group [ngrxFormControlState]="position.controls.Debit">
                    <div class="radio-container">
                        <mat-radio-button [checked]="position.controls.Debit.value" value="true">True</mat-radio-button>
                        <mat-radio-button [checked]="!(position.controls.Debit.value)" value="false">False</mat-radio-button>
                    </div>
</mat-radio-group>

Right now this throws an ExpressionChangedAfterItHasBeenCheckedError caused by the [checked] attribute.

I also have downloaded all the material fixes.

Is there any way to solve this?

Solved it by changing:
<mat-radio-button [checked]="position.controls.Debit.value" value="true">True</mat-radio-button>

to:
<mat-radio-button [value]="true">True</mat-radio-button>