Angular 2 - Routing - multiple :id in the url

447 views
Skip to first unread message

rafaeld...@gmail.com

unread,
Oct 25, 2016, 9:40:43 AM10/25/16
to Angular
Hi,

I would like to do it in a correct way that case, I would like to get multiple id from the url.

I have that code, but I don't like it. 

{path: 'dashboard/:id', component: DashboardComponent},
{path: 'dashboard/:id/:id2', component: DashboardComponent},
{path: 'dashboard/:id/:id2/:id3', component: DashboardComponent},
{path: 'dashboard/:id/:id2/:id3/:id4', component: DashboardComponent},

Any idea about how I can do it in the correct way?

Thanks,

Rafa


Nick Bachicha

unread,
Oct 25, 2016, 2:39:33 PM10/25/16
to Angular
You could do query parameters instead of route parameters. Angular.io Documentation for Query Parameters: https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters

Then you could have:
{path: 'dashboard', component: DashboardComponent} 

And then have the DashboardComponent check for parameters
Reply all
Reply to author
Forward
0 new messages