如何在订阅的 router.events 中获取事件路由数据(如参数)?
我不想订阅this.route.params!
// Catch any events in a certain component, where I subscribe to it!
this.router.events.subscribe(event =>
{
// The event object has only the url (when is NavigationStart/End), there is nothing useful for me
});
更新
我的问题不同,因为我不问如何对路由器事件使用react!
我询问如何在 router.events 中获取激活路由参数!
这肯定是不同的!
最佳答案
this.router.events.subscribe(event =>
{
console.log(this.router.routerState.root);
console.log(this.router.routerState.root.firstChild);
console.log(this.router.routerState.root.firstChild && this.router.routerState.root.firstChild.firstChild);
});
关于angular - 在 router.events 中获取事件路由数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41496316/