NavigationCancel 事件被触发的所有可能原因是什么? [英] What all could be the reasons for a NavigationCancel event to get triggered?

查看:34
本文介绍了NavigationCancel 事件被触发的所有可能原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我订阅了 angular2 中的路由器事件,当我控制事件时,我发现了一个 NavigationCancel 事件,reason: "".很想知道触发 NavigationCancel 的所有可能原因是什么.不仅有 empty 的原因,而且在一般情况下.

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 guard) 或路由本身不能被激活(CanActivate guard)

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 事件被触发的所有可能原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆