Issue
I have the following autocomplete
in Angular material:
<!-- Drop Down menu -->
<mat-form-field>
<input placeholder="Select one" [matAutocomplete]="auto" matInput>
<mat-autocomplete #auto="matAutocomplete">
<mat-option value="Cars">Cars</mat-option>
<mat-option value="Books">Books</mat-option>
</mat-autocomplete>
</mat-form-field>
Is there a way to disable typing on the input
so that the user does not defeat the purpose of the dropdown menu? Right now, the user can just type something instead of picking an option, or even edit an option when selected.
Solution
If you don't want the user to input anything in the input but instead only select from a list, why don't use a mat-select? The user can also select with the keyboard, typing what he needs. The docs: https://material.angular.io/components/select/overview
Answered By - Christian Benseler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.