Skip to content

Multiple async/await resulting in "Navigation triggered outside Angular zone" in NS7 Angular 10. #2308

@jcassidyav

Description

@jcassidyav

Environment
√ Component nativescript has 7.0.11 version and is up to date.
√ Component @nativescript/core has 7.0.13 version and is up to date.
√ Component @nativescript/android has 7.0.1 version and is up to date.
@angular/core 10.1.6
@nativescript/angular 10.0.0

Describe the bug
I am upgrading a project to NS7/Angular 10.
I have a button bound to an async method.
In the method if you await the result of something, then await a call to RouterExtensions.navigat(),
Then the error:
Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'
will be printed to the console.

There was no error in NS6 / Angular 8 in this scenario.

To Reproduce
<Button text="Log In" (tap)="onLogin()"></Button>

onLogin = async (): Promise<void> => {
        console.log("op1");
        await this.delay(1000);
        console.log("op2");
        await this.routerExtensions.navigate(["login"], { clearHistory: false });
    }

    async delay(ms: number) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions