I have an ionic app that uses ionic-selectable plugin and it works pretty good I must say. But I noticed on a fringe case If a user on a slow phone decides to click on a selection twice really really fast you get the error.
Error: Uncaught (in promise): IonicSelectable is disabled or already closed
This happens I think because component: IonicSelectableComponent is being called twice. So I want the onChange event to called only once and not be able to be called again on a second click that happens really fast after the first one.
How would I accomplish this?
HTML
<form #NameFour="ngForm">
<ion-item>
<ion-label class="ion-text-wrap" position="stacked">{{ 'NEW.countrycode' | translate }} <span style="color:red">*</span></ion-label>
<ionic-selectable
name="countrycode"
*ngIf="loadValue(i,p)"
placeholder="Please select country"
class="form-control"
required
[(ngModel)]="CountryInput"
[items]="countryCodesService.countryCodeArray"
itemValueField="code"
itemTextField="name"
[canSearch]="true"
(onChange)="changeCountryCode($event,i,p)">
<ng-template ionicSelectableItemTemplate let-CountryInput="item">
{{CountryInput.name}} [+{{CountryInput.code}}]
</ng-template>
<ng-template ionicSelectableValueTemplate let-CountryInput="value">
{{CountryInput.name}} [+{{CountryInput.code}}]
</ng-template>
</ionic-selectable>
</ion-item>
</form>
.ts
changeCountryCode(event: { component: IonicSelectableComponent, value: any },i: string |
number, p: string | number){
this.CountryISO = this.CountryInput.acronym;
this.CountryCode = this.CountryInput.code;
}