angular5 路由变化监听

1.路由监听

 

//监听路由变化
this.router.events
.filter(event => event instanceof NavigationEnd)
.map(() => this.activatedRoute)
.map(route => {
while (route.firstChild) route = route.firstChild;
return route;
})
.subscribe((event) => {
this.colorChange();
});

 

posted @ 2017-12-04 15:28  上帝不是要你成功,而是让你去尝试  阅读(1361)  评论(0编辑  收藏  举报