I am facing an issue where I need to display breadcrumbs with labels in a certain way. Specifically, when clicking on "/bbb" I want it to call "222." Despite my efforts to handle this situation, the output is not correct.
const url = "/aaa/2222/ccc"
const label = "/aaa/bbb/ccc"
breadcrumbs: any;
this.breadcrumbs = url.split('/')
.reduce((acc, cur, i) => {
const url1 = i === 0
? `${acc[i - 1].url1}/${label.split('/')[i]}`
: undefined;
const label1 = i === 0
? `${acc[i - 1].label1}/${url.split('/')[i]}`
: undefined;
const breadcrumb = {
url1,
label1
};
acc.push(breadcrumb);
return acc;
}, []);
var numbers = [175, 50, 25];
The current output displays "/aaa/bbb/ccc/aaa/bbb/ccc/aaa/sites/bbb/ccc/aaa/222". However, I require the UI to show "aaa/bbb/ccc" while the background should be "aaa/222/ccc."
Thank you.