Angular Router Events: NavigationEnd — How to filter only the last event
问题 I want to extract only the last event entry of type NavigationEnd from router.events. But somehow I can't find a proper way to do this. Whatever I try the following code snipped is the only way to get access to these objects of interest. let ne: any; router.events.filter(e => e instanceof NavigationEnd) .forEach(e => { ne = e as NavigationEnd; }); console.log('target page: ', ne.urlAfterRedirects); But do I really have to use .forEach() letting it run though all entries and using then the