K
K
Konstantin2020-11-03 04:24:17
Angular
Konstantin, 2020-11-03 04:24:17

Why doesn't disabled for formGroup work?

this.form = this.formBuilder.group({
            cadnum: [{ value: this.application?.cadnum, disabled: true }],
});


Sample:

<mat-form-field>
      <input matInput formControlName="cadnum" />
</mat-form-field>


Why is the element not disabled?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CoyoteSS, 2020-11-03
@Junart1

You can do it like this:

this.form = this.formBuilder.group({
  cadnum: this.application?.cadnum,
});
setTimeout((): void => {
  this.form.controls.cadnum.disable();
}, 0);

Either like this:
<input matInput formControlName=“cadnum” [disabled]=“disable”>

this.form = this.formBuilder.group({
  cadnum: this.application?.cadnum,
});
this.disable = true;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question