gmostert / ng2-breadcrumb

This is an angular 2 component that creates a breadcrumb trail. It hooks into the angular2/router, to dynamically build up the crumb trail once a component is routed to.
MIT License
102 stars 81 forks source link

Problems with simple Regex #80

Closed janhartmann closed 7 years ago

janhartmann commented 7 years ago

Hi and thanks for this piece of software!

I have a route like: /profile/424021007778888 and a setup like this

this.breadcrumb.addFriendlyNameForRoute("/profile", "Profile");
this.breadcrumb.addCallbackForRouteRegex(new RegExp("\/profile\/\d+$").toString(), s => this.profile.name[0].value);

Which correctly displays "Profile", but the last part of the URL (the number) is not converted to my profile name? According to https://regex101.com/r/UOYPE6/1 this should work? :-)

What am I missing here?

janhartmann commented 7 years ago

Apperently, it can be fixed with: this.breadcrumb.addCallbackForRouteRegex('/profile/[0-9]', id => this.profile.name[0].value);