Yassmeen Mahmoud Yassmeen Mahmoud - 1 year ago 233
Javascript Question

Angular2 routerLink params

My angular2 app has this routes configuration

export const AppRoutes: Routes = [
{ path: 'SignIn', component: LoginComponent },
path: 'Home', component: HomeComponent, canActivate: [LoggedInGuard]
, children: [
{ path: 'ViewUserDetails/:pageTitle', component: ViewUserDetailsComponent },

I wanted to use the pageTitle parameter in my component so I passed it in the routerLink this way

<a [routerLink]="['/Home/ViewUserDetails',{pageTitle:'View Channel User'}]">View Channel User</a>

But I get this error

core.umd.js:3257 EXCEPTION: Uncaught (in promise): Error: Cannot match
any routes. URL Segment:

The angular documentation used this to pass parameters I don't understand why it produces this form of the link instead of


Answer Source

Angular 2 router does work on URL fragment base. It navigates between route based on URL pattern.

You should be having just array of expression(here its string).

<a [routerLink]="['/Home/ViewUserDetails','View Channel User']">View Channel User</a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download