Alex
Alex

Reputation: 11

Best option to disabled input type formControlName matInput? Angular Material

I need best option to disabled input matInput type filed in Angular Material? Check my code:

<div></mat-label>
</div>

Upvotes: 0

Views: 1594

Answers (1)

Adithya Sreyaj
Adithya Sreyaj

Reputation: 1892

You can disable the formControl in your controller. Say I have a Form Group called myForm which contains a control called name. You can set the disabled to true when initializing the form.

const myForm = this.formBuilder.group({
   name: [{value:'',disabled: true}]
})

Or you can dynamically disable control using:

myForm.get('name').disable();

Upvotes: 2

Related Questions