Angular Router Events: NavigationEnd -- How to filter only the last event

Okay, after reading through the posted articles above and rethinking what I really want to achieve I found out that my approach was definitely too complicated. Because actually I only need access to the currently called route. And so I started from scratch and came across this small but very effective solution:

this.router.events.subscribe(value => {
    console.log('current route: ', this.router.url.toString());
});

Thanks to all who shared a comment in oder to support me! It helped al lot as I was able to tie up loose ends.


PS. There's a better way to filter using an instanceof typeguard, you then get the proper type without having to assert it again:

this.firstChildData$ = this.router.events.pipe(
  filter((e): e is NavigationEnd => e instanceof NavigationEnd),
  map(e => {
    // e is now NavigationEnd
  })
);

enter image description here