I would like to combine the autocomplete feature with a multiselect mat-select chooser because the optionslist will be quite long.
I've already searched on stackoverflow for the answer and the closest to an answer was this implement a search filter for the <mat-select> component of angular material
However the examples are about table and not mat-select.
My question is, is it possible to add the autocomplete feature to mat-select. And if not could i make an autocomplete that includes checkboxes in front of each item in the list?
Thank you
EDIT: I've found out that primefaces for angular does have a multiselect list that allows you to search for listitems. It also includes a builtin select-all button! You can find it here https://www.primefaces.org/primeng/#/multiselect
You can install primefaces with npm install primeng --save
You can implement an autocomplete multi-select using
MatAutocomplete
and some tricks. I'm fairly sure you can't do it withMatSelect
since that doesn't give you control over the input element. The technique is a little odd, but it works fine. The idea is to manage selections in your controller, and set the "value" of eachmat-option
to the same thing - your selected options. You also need to trap clicks to allow users to interact with the list (rather than have it close immediately when clicked), and of course provide checkboxes inside themat-option
items. A few other tricks are necessary as well - here is a quick and dirty example that shows what to do.HTML:
TS:
Yes you can use PrimeNG multiselect control. Only issue with that is if you are worried about themes.
There is another option using mat-select-autocomplet
How to install:
npm: https://www.npmjs.com/package/mat-select-autocomplete
Demo: https://stackblitz.com/edit/mat-select-autocomplete