Hello there,
in our application, we use the router
with child routers to navigate, which works fine.
We have a page containing a form. When the user wants to leave the form (for instance by clicking a navigation link), a warning message should be displayed asking the user whether he really wants to navigate away.
I implemented this successfully by using the canDeactivate()
lifecycle hook.
Additionally, in our navigation bar, there is a link which points to an external URL.
This link is called by using the router in the following way.
Create the route:
const config = { route: 'myRoute', name: 'myRoute', redirect: 'https://discourse.aurelia.io/' };
this.router.addRoute(config);
Call the route:
this.router.navigateToRoute('myRoute');
The routing to the external URL works fine.
However, the problem is that the canDeactivate()
is not called.
Additionally, I listen to the router:navigation:processing
event.
This event is fired, so I suppose the router is working fine. However, pipeline steps are not called…
Why is the canDeactivate()
hook not called and what can be done in order to make this work?
Thanks for any help!