I'm developing a contact change form for my application using FormGroup and FormControl with Angular 8. I set up several fields that are filled in advance if the information is already filled in for the contact. So I used this method several times to be able to set up the fields of my form: create several FormControls, push them into a FormControl array which will then be placed in a FormGroup. Everything works well except for one, the value always remains a null, even the method setValue() and patchValue() does not work.
Method used in general for all fields:
const controls = {};
let control = new FormControl({
value: fieldToValue(this.values, field.key, field, true),
disabled: this.locked
});
controls[this.prefix + field.key] = control;
this.group = new FormGroup(controls);
I tried this too but it doesn't work:
let value = '2';
control = new FormControl();
control.setValue(value);
Do you know what is preventing my FormControl from setting its value ?