Ion-list does not update on change from inside callback function

Hello,

i have a very strange problem.

I have an ion-searchbar, which calls a function “getItem()” onInput.

getItem() uses the google.PlacesService to retrieve the places/addresses which match my searchbar input.

Inside the callback function from PlacesService.textSearch(query, callback) i push() all found places to an array “items[]” which i use in <ion-item *ngFor="let item of items" >, to list the results.

Now The Problem:
The ion-list does not get automaticly updated/refreshed when i add a new item to the items[] array.I have to klick with my mouse anywhere on the screen, to “refresh” the list.

This only happens, if i push() values to the items[] array from inside a callback-function. If i push() values from a normal function, the ion-list gets updated instantly (as it should),

var service = new google.maps.places.PlacesService(this.gmap.getMap());

getItems(value) {

  this.items = [];  // This is "bound" to an ion-item element with *ngFor="let item of items"

  if (value.value != "") {

    this.service.textSearch({
      query: value.value
     }, this.callback);
  }

}

callback (results, status) {

        if (status === google.maps.places.PlacesServiceStatus.OK) {

          for (var i = 0; i < results.length; i++) {
            
            this.items.push(results[i].formatted_address);
          }

        }
      }

Does anyone had this Problem too ? Is there any way i can “fix” this ?

Thank you :slight_smile:

This is a zone problem. Can you try using the ionic-native shim code? It will probably deal with this.

Hi rapropos.

thanks for the fast answer. I dont rly know what you mean with “ionic-native shim code”.
Can you help me there ? :slight_smile:

Thank you

Look through here for map-related stuff that might help you.