2

still struggling with the new component router as of Angular2 RC.1.

My app's components are assembled in this manner:

Main
 - NavigationBarComponent
 - ContentComponent
   - UserComponent
     - UserSettingsComponent
     - UserNotificationComponent
   - CarComponent
     - CarDetailsComponent 
     - ...

The routing works fine for ContentComponent and all its child components. The issue is creating routes within the NavigationBarComponent, which is a permanently visible component offering some shortcuts to components.

If I assemble a link from the NavigationBarComponent to the UserSettingsComponent, the route should look like this:

/user/:id/settings

I managed to create such a link with this:

<a [routerLink]="['/user/'+loggedInUser.id+'/settings']">

Concatening a link like this seems pretty ugly and wrong, though. I've tried a syntax like it was used in the deprecated routing of the beta versions

 <a [routerLink]="['/user/:id/settings',{'id':loggedInUser.id}]">

but the output looked like this:

/user/:id/settings;id=56edad04c506d7e7963edd48

I couldn't find any examples for this requirement in the docs or live examples. Any suggestions? Thanks in advance.

Jan B.
  • 6,030
  • 5
  • 32
  • 53

1 Answers1

2

It should be:

<a [routerLink]="['/user', 'loggedInUser.id', 'settings']">
Morteza Manavi
  • 33,026
  • 6
  • 100
  • 83