When creating a form group with existing values:
this.form = new FormGroup({
field1: new FormControl(
{
value: obj ? obj.value : null,
disabled: obj
},
Validators.required
),
field2: new FormControl(
{
value: obj ? obj.value : null,
disabled: obj
},
Validators.required
)
});
Example: https://stackblitz.com/edit/angular-aadkss
My intention is to have the values filled, valid, and disabled when 'obj' exists, but currently they are being filled, disabled, and marked as invalid. How can I ensure that they are valid instead?