This is my code: <mat-form-field [disabled]="isDisabled"> Which gives me the error: Can't bind to 'disabled' since it isn't a known property of 'mat-form-field'.
UPDATE:
This is how I solved it. In my case, I actually needed to disable the whole form rather than just the single field.
HTML:
<mat-form-field [formGroup]="myForm">
<mat-select formControlName="myControl">
<mat-option>my first option</mat-option>
<mat-option>my second option</mat-option>
</mat-select>
</mat-form-field>
JS:
//declare the form
myForm: FormGroup;
ngOnInit() {
this.myForm = this.formBuilder.group({
myControl: ['']
});
this.myForm.disable();
}
// use the enable and disable methods to toggle between states
if (myCondition) {
this.myForm.enable();
}
else {
this.myForm.disable();
}