I’ve got a searchbar in my Ionic 3 project:
<ion-searchbar animated="true" showCancelButton="true" (ionInput)="onSearch($event)" (ionCancel)="onSearchCancel($event)"></ion-searchbar>
The problem is, when I click the cancel button, my
onSearch() method is being called. Any idea why?
It’s a problem because I’m using an
*ngIF structural directive to display the results.
onSearch() sets a variable to
true (showing the result template), and
onSearchCancel sets the variable
false again to hide the results. This works, but for some reason,
onSearch() is called by
(ionCancel) so the final result is that the variable ends up set
Any help appreciated!