I need some help with breadcrumbs
Here example routes config
Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: 'home', ..., data: { breadcrumb: 'Home'}},
{path: 'about', ..., data: { breadcrumb: 'About'}},
{path: 'github', ..., data: { breadcrumb: 'GitHub'},
{
path: 'category/:id',
component: CategoryComponent
},
]
In bread crumbs component i try to use this to extract breadcrumbs data from ActivatedRoute
ngOnInit() {
// subscribe to the NavigationEnd event
this.router.events.filter((event) => event instanceof NavigationEnd).subscribe(() => {
// set breadcrumbs
const root: ActivatedRoute = this.activatedRoute.root;
this.breadcrumbs = this.getBreadcrumbs(root);
});
}
After that i render comonentns template
<ul class="breadcrumb">
<li><a routerLink="" routerLinkActive="active"><i class="fa fa-home position-left"></i> Главная</a></li>
<ng-container *ngFor="let breadcrumb of breadcrumbs">
<li routerLinkActive="active">
<a [routerLink]="[breadcrumb.url, breadcrumb.params]"> {{ breadcrumb.label }}</a>
</li>
</ng-container>
</ul>
All fine but i dont know how i can pass data value from another component for category/:id
route for make in human readable like "Mobile Phones"