Search code examples
angularmat-select

How to add new set of options in mat-select


Want to add new set of options on selectChange event of mat-select. is it possible?

sample - https://stackblitz.com/edit/angular-gtc9hx-f43vwp?file=app%2Fselect-overview-example.ts

Above is my sample, on that i have rendered 2 mat-select. on selectCHange event i am passing corresponding mat-select reference and trying to empty options and try to assign new data's but I can't.


Solution

  • I modified your example a little bit to get it to work.

    The Options itself are being stored in a QueryList which cannot be modified. See https://angular.io/api/core/QueryList.

    https://stackblitz.com/edit/angular-gtc9hx-wsfqjs?file=app%2Fselect-overview-example.ts