UI does not update on property change

When you update component values inside functions form other libraries, Angular 2 doesn’t trigger the change, so you may need to correctly use arrow functions to avoid that, or use NgZone as last resource:

import { Component, NgZone } from "@angular/core";
...

export class MyComponentPage {
  constructor(
    private zone: NgZone,
    ...

  ionViewLoaded() {
    ...
    google.maps.event.addListener(this.map, 'dragend', () => {
      this.zone.run(() => {
        this.mapMoved = true;
      });
    });

In this example I needed to use the zone because it wasn’t updated properly on the Google Maps event.

7 Likes