angular2-routing

Angular 2 router event not firing first time?

自作多情 提交于 2020-07-18 08:41:52
问题 I am routing from one component to another. Once the route is done I would like to use the URL from the previous route. I have put the code below into the constuctor of the component being routed to, but it does not fire on the first route. After the first route, the function fires every time. this.router.events .filter(e => e instanceof NavigationEnd) .pairwise().subscribe((e) => { console.log(e); }); If I remove the pairwise function it seems to fire on first route, however it lists only