Search code examples
angularangular2-routing

What all could be the reasons for a NavigationCancel event to get triggered?


I have a subscription for router events in angular2, When I console the events, I find a NavigationCancel event with reason: "". Curious to know what all could be the reasons for a NavigationCancel to get triggered. Not only with an empty reason but in general.


Solution

  • NavigationCancel will be triggered when you are trying to naviggate to a route and navigated route children can not be loaded (CanLoad guard) or route itself cannot be activated (CanActivate guard)

    you may use {enableTracing : true} while configuring RouterModule to see all events, and analyze further.

    Hope this helps!!