My angular reactive form is not able to set the UI state of the radio button, I'm trying to load a from state for a 'saved search' feature of an app
I'm using angular 7 and angular material
//declaration
this.filterForm = new FormGroup({
heating: new FormControl('1'),
});
//loadSearch fuction
this.filterForm.setValue(valueObject);
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="heating-1" >
<input formControlName="heating" id="heating-1" type="radio" name="heating" (change)="onFilterCheckChange($event,'heating')" class="mdl-radio__button" [value]=1 checked>
<span class="mdl-radio__label">Si</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="heating-2" >
<input formControlName="heating" id="heating-2" type="radio" name="heating" (change)="onFilterCheckChange($event,'heating')" class="mdl-radio__button" [value]=0 >
<span class="mdl-radio__label">No</span>
</label>
Expected result is that form UI gets updated when i call .setValue in loadSearch fuction, actual result is that nothing happens to the UI (but the formControl object has the correct value)
checked: Angular decides what to check based on the model, which is the source of truth. 3. What is the value ofvalueObject? 4. You initialize the control with the string '1', but the two possible values are the numbers 0 and 1. Post a complete minimal example reproducing the problem, as a stackblitz.