.html:
<ion-searchbar
#input
[(ngModel)]="searchTerm"
[formControl]="searchCtrl"
(ionInput)="onSearchInput()"
placeholder="Search...">
</ion-searchbar>
.ts:
ionViewDidLoad(){
this.searchCtrl.valueChanges.debounceTime(700).subscribe(search => {
this.searching = false;
if (this.searchTerm !== ''){
// do something
} else {
this.hideDefaultList = false;
}
});
onSearchInput() {
this.searching = true;
this.showMessage = false;
this.hideDefaultList = true;
}
when closing keyboard , the function onSearchInput
triggers again leading to show spinner this.searching