xng-breadcrumb
xng-breadcrumb copied to clipboard
Using Angular resolver in breadcrumb as a function
🧩 Feature request
Description
I would like to be able to construct a breadcrumb item using data retrieved with an Angular resolver. Maybe by leveraging breadcrumb as a function ?
{
path: '/orders',
children: [{
':id',
resolve: {
resolvedOrder: 'orderResolver'
},
data: {
breadcrumb: (resolvedOrder: Order) => `Viewing order number ${resolvedOrder.orderNumber} now`
}
}]
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
@fgoulet I have solved this. We will have additional data passed to the breadcrumb label function which you can use to read the resolved data.
resolve: {
name: DemoResolver,
},
data: {
breadcrumb: (breadcrumb, activatedRouteSnapshot) => {
return `Viewing ${activatedRouteSnapshot.data.name} instead of ${breadcrumb} now`;
},
},
Cool, looks like a good solution.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
@fgoulet I have solved this. We will have additional data passed to the breadcrumb label function which you can use to read the resolved data.
resolve: { name: DemoResolver, }, data: { breadcrumb: (breadcrumb, activatedRouteSnapshot) => { return `Viewing ${activatedRouteSnapshot.data.name} instead of ${breadcrumb} now`; }, },
Hi! Can you please explain where activatedRouteSnapshot comes from? I tried to set on the breadcrumb a value taken from the resolver with the help of activatedRouteSnapshot, but it seems that activatedRouteSnapshot is undefined.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.