0

I am using google matrix api to get distance and duration in my ionic 2 application.Problem which i am facing is that ,since the google api take some time to load i am able to insert values from google api to javascript array object only after the page is rendered

  • values are getting inserted into array object but not showing up in view
  • if i interact with UI lets just say press a button or a drop down then inserted values from google api appears

please suggest what might be correct way to tackle this problem ,any help is greatly appreciated

Abhijeet
  • 87
  • 9

1 Answers1

1

Usually when the view is not updated with data changes, it means something broke out of Angular's zone.

When your code runs outside of the Angular zone, the Change Detector could not detect the changes, and the view will not update.

To force change detection - you should explicitly run your code inside the Angular zone using the zone.run() method (docs).

See this answer for more options how to force change detection.

Community
  • 1
  • 1
naomi
  • 2,583
  • 2
  • 22
  • 39