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

Regex/:id not working #83

Closed lginq closed 7 years ago

lginq commented 7 years ago

I have a route accounts/123456/overview.

When I try to match specific route with this regex to replace the id parameter with correct name: breadcrumbService.addCallbackForRouteRegex("accounts/\d+/overview", this.getName)

I don't get anything, my callback function isn't called.

Any help?

lginq commented 7 years ago

I found a solution. The thing is you need to specify friendly name for every route. Things I did to make this work:

ahelord commented 6 years ago

@lginq how can I do this

getNameForUser(id: string): string {
   let name = '';
   this.userService.getUserByIdUser(+id)
     .then(userRespond => {
       name = userRespond.first_name;
       return name
     })
 }