View not updated but model does. ngZone issues?


I’m working on an app that have to reload data from some services upon resume.
Services are inited and filled in app.ts and then injected on pages. I’ve then added a resume listener that call data services reload on resume event, and it works, as I can see the logs in the server and data is updated.
The problem is that views are not reloaded until I do an action in the page, and then the view reload is so fast that you can see it updated before the transition to another page or show a modal.

I’ve read that this could be related to ngZone issues on old betas, but I don’t know how to debug it.
Could somebody give me some hints?

In case that you updated your project from an earlier version of the framework I would suggest to check if you performed the update properly. If you missed something by the update, it might result in such problems. Check out the following post for more details:

I’d checked that thread and verified es6-shim or node version. I even migrate app to a new folder,
and did a diff compare with conference app to look for possible problems, bit it didnt help.

Could you provide some code or try to reproduce the problem using the following plunker as template?

Solved with beta.9 I guess.
My issue is that I’ve to consume some services to keep the UI updated when app resumes.
I was doing so by a listener on cordova resume. Simplified code bellow:


        this.platform.ready().then(() => {;
    addListener() {
        var me = this;
        var onResume = function () {
        document.addEventListener('resume', onResume, false);

It was not working, but the same call done from a button was working.

I’ve seen in ionic code that with beta.9, resume event runs inside a zone, and probably that did the trick. (IMVHO)


1 Like

Yes, most probably, great that it solves your problem.

I spoke too soon…
It seems that sometimes works, but not always.
If I press overview or home button (sending the app to background), and after a while press overview again and open the app, the values got updated. I can repeat this with no problem.
But it seems that when phone is locked or time interval is greater, If I open the app or resume it from overview buttton, the getDataservice is called and I got logs in the server, but the UI is not updated until I do some action.

You could check in which zone your code is executed as explained in the linked post:

Solved by calling data service through zone

Without this, resume event works fine if phone is not locked, but never worked when app comes from background if phone was locked.

Also I’ve changed the code a bit, just for being more ts (but it didn’t work until I add NgZone run)

  addListener() {
    document.addEventListener('resume', () =>{

I also used this solution to force a view update on the resume event. See: