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();
});