Is there a way to remove an item from a dropdown list once it has been selected? For example, if I have a dropdown box with options 'Dog', 'Lion', and 'Cat', how can I make it so that once I select 'Dog', it will no longer show in the dropdown list? Is this achievable?
Here is the HTML code:
<mat-form-field class="full-width" floatLabel="always" appearance="outline">
<mat-label>Choose Animal</mat-label>
<mat-select formControlName="animal">
<mat-option *ngFor="let items of animal" [value]="items.id">
{{items.animal}}
</mat-option>
</mat-select>
</mat-form-field>
And here is the TS code:
ngOninit() {
this.getList()
}
getList() {
this.animalSVC.getListOfAnimal().subscribe((response: AnimalDTO) => {
this.animalObj = response;
this.animalDS = this.animalObj.items
})
}
So, for example, if I select 'Lion' from the list, it should not be available for selection again in the dropdown box.