disable reactive form control angular 8 code example
Example 1: how to set disabled flag formgroup angular
this.form.controls['name'].disable();
<input formControlName="id" placeholder="ID" [attr.disabled]="true"></input>
Example 2: form control adding disabled and validators
value: string;
isDisabled: boolean;
fb: FormBuilder;
myGroup: FormGroup;
this.myGroup = fb.group({
form_control_name: new FormControl({
value: this.value,
disabled: this.isDisabled,
Validators.required)}
);
Example 3: disable formcontrol angular
this.form.controls['name'].disable();