xng-breadcrumb icon indicating copy to clipboard operation
xng-breadcrumb copied to clipboard

Using Angular resolver in breadcrumb as a function

Open fgoulet opened this issue 3 years ago • 13 comments

🧩 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`
    }
  }]
}

fgoulet avatar Jun 12 '21 14:06 fgoulet

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.

stale[bot] avatar Jul 12 '21 16:07 stale[bot]

not stale

udayvunnam avatar Jul 14 '21 01:07 udayvunnam

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.

stale[bot] avatar Sep 12 '21 03:09 stale[bot]

not stale

udayvunnam avatar Sep 19 '21 02:09 udayvunnam

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.

stale[bot] avatar Mar 17 '22 10:03 stale[bot]

not stale

udayvunnam avatar Mar 17 '22 11:03 udayvunnam

@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`;
          },
        },

udayvunnam avatar Mar 27 '22 04:03 udayvunnam

Cool, looks like a good solution.

fgoulet avatar Mar 27 '22 12:03 fgoulet

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.

stale[bot] avatar Jul 30 '22 16:07 stale[bot]

not stale

udayvunnam avatar Aug 03 '22 05:08 udayvunnam

@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.

luizagabriela avatar Sep 27 '22 14:09 luizagabriela

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.

stale[bot] avatar Feb 02 '23 03:02 stale[bot]

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.

stale[bot] avatar Oct 15 '23 15:10 stale[bot]