Marc-André Therrien Marc-André Therrien - 3 months ago 44x
AngularJS Question

Angular 2 ngModel value not updating fast enough using ionic

I have a

that looks like this

<ion-searchbar [(ngModel)]="searchQuery" (keyup.enter)="search();"></ion-searchbar>

and the
is defined in my typescript file like this

export class SearchPage {
searchQuery: string;


search() {
data => this.searchResults = data,
error => {
}, () => {

The problem is that if I change the value too fast and I press Enter, the value of
is not updated. For example, if I search "test" and I wait two seconds it will work. If I then search "testing" and I type it fast and press Enter right away, the value will still be "test". Now, I know this sounds weird, but it is really happening!

Any ideas why the value is not changed as soon as I type something?

Thank you


I found the solution in the link given by mayur. I replaced the ngModel and the keyup.enter event by (ionInput)="search($event)". In my typescript file, I get the search value like this

search(event) { var searchQuery =; //do something }