Searchbar's ionInput not triggering after upgrading to beta.9


#1

I upgraded my app to ionic beta.9 by changing package.json and then remove and reinstall with npm i, everything went fine. I then did ionic serve and opened the app in my browser, I did a seach in a searchbar component that worked before the upgrade. There was no error in google dev tools, not sure what’s happening there.


#2

There are some changes with the searchbar. I had the same issue and I looked here to solve it:

https://github.com/driftyco/ionic/commit/31c7e59

In the .html where the searchbar is you can remove the ngModel part. So now you can write:

<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>

In the .ts file you must change this:

if (q.trim() == '') {

to

if (!q || q.trim() === '') {

and

getItems(searchbar) {

to

getItems(ev: any) {

and

var q = searchbar.value;

to

var q = ev.target.value;

Now it should work again :slight_smile:


#3

Debugged again this morning, strangely it started to work. Without any code changes. With

handleInput(searchbar) {

  console.log(searchbar);

}

I managed to output searchbar in the console, there is no searchbar.target.value, just searchbar.value.

I’m a bit confused since in my package.json

{
    "@angular/common": "^2.0.0-rc.1",
    "@angular/compiler": "^2.0.0-rc.1",
    "@angular/core": "^2.0.0-rc.1",
    "@angular/http": "^2.0.0-rc.1",
    "@angular/platform-browser": "^2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
    "@angular/router": "^2.0.0-rc.1",
    "es6-shim": "^0.35.0",
    "ionic-angular": "2.0.0-beta.9",
    "ionic-native": "^1.1.0",
    "ionicons": "3.0.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12"
  }

I guess my question is since beta9, what would the structure of searchbar in handleInput(searchbar) be?

Thanks.


#4

@iNono After restarting ionic serve, the parameter became the event … like you pointed out.