router.navigateByUrl not working on specific route


Hello guys…
I’m currently facing a really weird bug in my app… I’ve updated the angular dependencies to version “~4.4.0”, and now there’s a ‘cart summary’ view that contains a button. When I click the button, it shows a modal and depending of what the user selects, it triggers a this.router.navigateByUrl('/cart/address').then(()=>{ console.log('navigaded...')}).
The problem is: If I do the steps to add a item to the cart, then go to summary, then click the button, no navigation happens, even though I see the ‘navigated’ on the console, but if I then close the app, then go to summary, then click the button, it works normally…
I even tried with different routes, but all of them with the same result…
does anyone have any idea of what can be the problem?

When going trough the “add to cart” steps, on the last step there’s a route with the clearHistory flag enabled, and in the cart summary there’s a handler to the ‘activityBackPressedEvent’:
if (!this.router.canGoBack()) { data.cancel = true; this.router.navigateByUrl('/').then(() => { this.ngOnDestroy ? this.ngOnDestroy() : console.log('already destroyed'); }); }


Clear history seems to be pretty unpredictable with Nativescript Angular right now. I would personally classify it as unstable.

For instance this issue outlines a large bug around it:

A solution that I have found, although “hacky”, is to run the navigation event inside a timeout and a zone.

setTimeout(() => { => {
        this.router.navigate(['/app/dashboard/user'], {
            clearHistory: true
}, 300);

Where zone is NgZone from @angular/core. It’s hard to tell if this is the problem you’re facing, but it’s worth a shot.


Thanks for your help.
I’ve tried your solution, but unfortunately it didn’t work.
Looks like my problem is the same as the issue you linked, so for now, removing the clearHistory flag solved the problem, and since I can’t allow the user to go back to the previous route, I’ve added a handler to the activityBackPressedEvent, redirecting him to the app main page, which is OK for now…