I have an Ion Select with Ion Select options generated dynamically. Sometimes there may be only one ion select option (as the user has only created one project, for example) available for the Ion Select.
When the user clicks on a select option it opens a project page, I want to give the user the option to re-select the same project again and thus clear the previous selection
I've tried binding a NgModel and set it to null as per:
ion-item-options not displaying
<ion-select mode="md" interface="popover" style="position: absolute; opacity: 0;" #projectSelect
(ionChange)="selectProject(projectSelect.value, p)"
[(ngModel)]="selection">
<ion-select-option *ngFor="let b of p.buildings; let i = index" [selected]="false" [value]="b.buildingName">
{{b.buildingName}}
</ion-select-option>
then in selectProject()
I set
selectProject(buildingName: string, project: Project) {
// always! reset the selection
this.selection = null;
but it does not clear the selection and the user is unable to re-select a previously selected option.
I have even tried having a button
with (click)=clearSelection()
setting selection=null
to no avail.
I was expecting the selection to be cleared and to allow the user to re-select the ion select.