#breadCrumb

13 messages · Page 1 of 1 (latest)

next summit
#

I want to make a dynamic breadcrumb using routing, I want to know what is the best way to do this?

royal stream
#

Hey @next summit 👋 Can you provide more details when you are saying dynamic?

next summit
royal stream
#

You can register to listen for all router events in your shared component using the Router.events observable.

next summit
next summit
royal stream
royal stream
next summit
next summit
#

this.route.events
.pipe(filter((e: any): e is RouterEvent => e instanceof RouterEvent))
.subscribe((event: RouterEvent) => {
if (event instanceof NavigationEnd) {
console.log(event.url);
}
});

royal stream
#

Yes, the data property in the route configuration object works fine for your use case. However, if you use it, you do not need to subscribe to router events. You can just simply subscribe to the data observable of the ActivatedRoute service inside your shared component 😉

next summit