I am using newest version mat-select v 16. When a particular option is selected and we click the select drop-down the selected option shouldn’t show in options list. This is what I am using in html.
<mat-form-field>
<mat-select formControlName="value" selected="option1">
<mat-option *ngFor="let item of options"
[value]="item.value">{{ item.label }}</mat-option>
</mat-select>
</mat-form-field>
items consist of option1, option2, option3.
What do I need to use so that whenever option1 is in selected only option2 and option3 should show in dropdown??
Please reply!! TIA!!!
2
Answers
you can do something like that by adding a class to hide the selected country via CSS
Try this:
1- In your TypeScript component, declare the selectedOption variable as an empty string and create a method to set its value:
2- In your HTML, use this method to assign the selected value to selectedOption
Now, when you click on an option, the setSelectedOption method will be called to update the value of selectedOption with the selected option.