question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using params within breadcrumb label

See original GitHub issue

I’m part way through integrating this library into a mature app and am really impressed with how flexible and powerful it is. Great work!

One quirk of our existing routing is that from a list page /items, an individual item would be located at /items/view/X452.

The path for this route is expressed as:

{
  path: '/items',
  children: [{
    'view/:id'
  }]
}

And the auto generated breadcrumb trail is

Home / Items / view/X452

I can resolve this on per page basis by using breadcrumbService.set, but given the data I want is already in the params, it would be nice for the breadcrumb label to be able to interpolate these values.

A more common use-case for this might be:

{
  path: '/orders',
  children: [{
    ':id',
    data: { breadcrumb: 'Viewing order :id` }
  }]
}

Which would generate

Home / Orders / Viewing order 45

I have assumed a simple interpolation syntax in the breadcrumb label above.

I’ve had a look at the code and would be reasonably confident creating a pull request for this, but I wanted to raise it as a feature request first to gather your feedback on the idea.

Thanks! 🙂

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
udayvunnamcommented, Sep 2, 2020

@chad-smith I am close to having an implementation similar to

breadcrumb: (id, ...rest){
 return `Viewing order ${id}`
}

This will be released in next minor version

0reactions
udayvunnamcommented, Sep 8, 2020

Yes this is a bug. We don’t need user to specify ~{breadcrumb: { alias: '@id' } }~ we just need {breadcrumb: { alias: 'id' } } with breadcrumbService.set('@id', 'MapingLabel').

This bug slipped since I changed the tests verifying alias to test breadcrumb as a function. Going to add a fix and additional test for this.

Thanks! Fix has been released with 6.1.1 @chad-smith

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular - Using Params in Breadcrumbs - Stack Overflow
Below is the code I use, Hope it helps. Sample on Stackblitz. TS FILe import { Component, OnInit, ChangeDetectionStrategy } from ...
Read more >
params-xng-breadcrumb - npm
Start using params-xng-breadcrumb in your project by running `npm i params-xng-breadcrumb`. There are no other projects in the npm registry ...
Read more >
Angular2 Breadcrumb using Router - Brian F Love
A breadcrumb has two required properties: label and url , both of which are strings. The params property is not required and is...
Read more >
Request parameters and content examples for use in ... - IBM
The following code adds the breadcrumbs attribute to the page. The breadcrumbs attribute contains the list of label keys for the breadcrumbs attribute....
Read more >
How To Add Breadcrumb (BreadcrumbList) Markup
itemListElement. ListItem. An array of breadcrumbs listed in a specific order. Specify each breadcrumb with a ListItem . For example: { "@context": "https:// ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found