rxjs5(angular6应用程序)中,我使用
this.router.events .filter(event => event ).map() => this.activatedRoute) .map(路由=> { while (route.firstChild) {en21= route.firstChild;}返回路径;enter code here }) .filter(路由=> route.outlet === 'primary') .mergeMap(路由存储)(事件){(事件标题‘+’+);this.appDataLogic.urlChanged();};rxjs6中,route是{},所以有错误property firstChild does not exist on type {}。
this.router.events.pipe( NavigationEnd的事件事件实例),map(() => {返回this.activatedRoute }).pipe(),map(路由=> {NavigationEnd= route.firstChild;}返回路由;}),过滤器(路由=> route.outlet === 'primary'),mergeMap(路由=> route.data) .subscribe(事件).subscribe(事件) => (事件‘标题’+‘’);})发布于 2018-09-21 05:40:46
谢谢你的回答,我找到了一个解决办法:
this.router.events.pipe(
filter(event => event instanceof NavigationEnd), map(() => this.activatedRoute), map(route => { while (route.firstChild) { route = route.firstChild; } return route; }), filter(route => route.outlet === 'primary'), mergeMap(route => route.data)).subscribe((event) => { //some code})但是我还有另一个问题,它在ngOnInit()中app.component.ts中使用,app.component.ts是我的根组件,如果我在ngOnDestroy()中取消订阅它
https://stackoverflow.com/questions/52435848
复制相似问题