How do I get active route data like params inside the subscribed router.events?
I do not want to subscribe to this.route.params!
// Catch any events in a certain component, where I subscribe to it!
this.router.events.subscribe(event =>
{
// The event object has only the url (when is NavigationStart/End), there is nothing useful for me
});
UPDATE
My question is different because I do not ask how to react to router events!
I ask for how to get the activate route params within the router.events !
Thats a difference for sure!
this.router.events.subscribe(event =>
{
console.log(this.router.routerState.root);
console.log(this.router.routerState.root.firstChild);
console.log(this.router.routerState.root.firstChild && this.router.routerState.root.firstChild.firstChild);
});
merge(of(this.route.snapshot.params), this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
map(() => this.route),
map((route) => {
while (route.firstChild) route = route.firstChild;
return route;
}),
filter((route) => route.outlet === 'primary'),
mergeMap(route => route.params),
)).subscribe(p => {})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With