问题描述
我在 angular2
中订阅了路由器事件,当我对这些事件进行控制台时,我发现了一个 NavigationCancel
事件,其原因是 reason:"
.好奇地想知道是什么导致 NavigationCancel
被触发的原因.
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.
推荐答案
NavigationCancel
会在您尝试导航到某个路线并且无法加载导航的路线子级(CanLoad保护)或路由本身无法激活(可以激活保护)
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)
您可以在配置 RouterModule
时使用 {enableTracing:true}
来查看所有事件并进行进一步分析.
you may use {enableTracing : true}
while configuring RouterModule
to see all events, and analyze further.
希望这会有所帮助!
这篇关于导致NavigationCancel事件被触发的原因全是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!