Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable mat-form-field or mat-autocomplete if list is empty?

I want to disable mat-form-field and/or mat-autocomplete if source list is empty. I've tried disable="true" (disable=list.empty) on mat-form-field and doesnt work.

Here's stackblitz: https://stackblitz.com/angular/dnbdkokmnelo?file=app%2Fchips-autocomplete-example.html

What if the fruits list was empty?

I'm looking for something like disabled mat-select...

https://stackblitz.com/angular/rkdgkaerxdk?file=app%2Fselect-disabled-example.ts

like image 752
Esteban Chornet Avatar asked Oct 18 '25 05:10

Esteban Chornet


1 Answers

If you want to disable MatChipList just write [disabled]="true" in mat-chip-list tag. Now the user can not remove chips anymore.

If you want to disable the input field, just write [disabled]="true" in the input tag.

Of course you can use any condition instead of true

like image 161
miladfm Avatar answered Oct 19 '25 20:10

miladfm