Nativescript-angular: Cannot read property 'reusedRoute' of undefined.

Created on 12 Jul 2017  路  2Comments  路  Source: NativeScript/nativescript-angular

I'm trying to navigate to a different route if the back button is pressed to a component.


this.page.on('navigatingTo', (args: NavigatedData) => {
        if(args.isBackNavigation) {
            this.router.navigateByUrl('/', { clearHistory: true });
        }
});

question

Most helpful comment

Thanks!.
Sorry for the delay in response.
This actually did the trick. Thanks again.
But instead of having to do this, it would have been better to achieve using Angular's implementation skipLocationChange so the route is not even added to the stack in the first place

All 2 comments

Hi @jogboms,
I tested this scenario on my side and found that this problem has been caused due to fact that you are making the navigation too early, when the Page is not fully loaded.
Something that I could suggest is setting a timeout of 100 milliseconds, which will allow properly loading the page and making navigation successfully.

setTimeout(()=>{
                    this.routerExtensions.navigate(['/action-bar/title'], { clearHistory: true });
                }, 100);

Thanks!.
Sorry for the delay in response.
This actually did the trick. Thanks again.
But instead of having to do this, it would have been better to achieve using Angular's implementation skipLocationChange so the route is not even added to the stack in the first place

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rowdyrabouw picture rowdyrabouw  路  34Comments

tsonevn picture tsonevn  路  33Comments

ignaciofuentes picture ignaciofuentes  路  31Comments

NathanWalker picture NathanWalker  路  32Comments

martijnvanschie picture martijnvanschie  路  23Comments