-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
Description
Hi emilol,
First of all, nice component, I´m currently using it within a real project and it works nice with just a few improvements.
I would like to propose the following improvement (Im at work and do not have much time to make a pull request):
- Just change the method createBreadcrumb() from here https://github.com/emilol/angular-crumbs/blob/master/src/breadcrumb.service.ts#L63 with the following:
private createBreadcrumb(route: ActivatedRouteSnapshot, url: string): Breadcrumb {
// Generates display text from data
// -- Dynamic route params when ':[id]'
let d = '';
const split = route.data['breadcrumb'].split(' ');
split.forEach((s: string) => {
d += `${s.indexOf(':') > -1 ? (route.params[s.slice(1)] ? route.params[s.slice(1)] : '') : s} `;
});
d = d.slice(0, -1);
return {
displayName: d,
terminal: this.isTerminal(route),
url: url,
route: route.routeConfig
};
}
- This way, now it is possible to customize more the displayName:
- Static displayName (like now):
{ path: 'home', ... , data: { breadcrumb: 'Home' } } - Or a Dynamic displayName:
{ path: ':yearId/:monthId/:dayId', component: SubhomeComponent, data: { breadcrumb: 'SubHome with Year :id Month :monthId Day :dayId} }
Regards :)