1

How do we update component data, inside a app event? this.matches = x gets ignored

import * as app from "tns-core-modules/application";

export class HomeComponent implements OnInit {
    matches; // How to refresh this??

    constructor() {
        app.on(app.resumeEvent, (args: app.ApplicationEventData) => {

            // how to change matches here??
        });
    }
}
1
  • Youe question is not very much clear? What do you want to update in resumeEvent? How do you get the initial value of matches? you can use the same method in resumeEvent Commented Dec 27, 2018 at 21:38

1 Answer 1

2

You have to run your code inside NgZone as resume event will be triggered outside Angular's context.

constructor(ngZone: NgZone) {
    app.on(app.resumeEvent, (args: app.ApplicationEventData) => {
         ngZone.run(() => {
            // Update here
         });
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.