我正在尝试在父组件中检查活动子路由,但是遇到了困难。
我尝试通过以下方式订阅ActivatedRoute:
class ParentComponent {
constructor(private _route:ActivatedRoute) {}
ngOnInit() {
this._route.data.subscribe(value => console.log(value)});
}
}
我在Stack Overflow上阅读了很多帖子,但找不到一个解决方案来检查并获取父组件的子路由的更新。
有什么想法吗?
属性'url'在类型“Event”上不存在 属性'url'在类型“RouteConfigLoadStart”上不存在
- Aakriti.GNavigationEnd
事件。this.router.events.filter(evt => evt instanceof NavigationEnd)
(可能需要断言类型为Observable<NavigationEnd>
,像这样:this.router.events.filter(evt => evt instanceof NavigationEnd) as Observable<NavigationEnd>
) - n00dl3