Angular-2 support Query Parameters but shown in different view in browser address bar. some time shown like as /heroes?id=15&foo=foo and some time shown as /heroes;id=15;foo=foo.
You should know when will show /heroes?id=15&foo=foo and when will show /heroes;id=15;foo=foo
/heroes?id=15&foo=foo will show in browser url when route is parent route
/heroes;id=15;foo=foo will show in browser url when route is child route
but from both both url can get id by using routeParams.get() like:
constructor(routeParams: RouteParams) {
this._selectedId = +routeParams.get('id');
})
when URL separated by semicolons (;) that means this is matrix URL notation
Matrix URL notation is an idea first floated in a 1996 proposal by the
founder of the web, Tim Berners-Lee.
Although matrix notation never made it into the HTML standard, it is
legal and it became popular among browser routing systems as a way to
isolate parameters belonging to parent and child routes. The Angular
Component Router is such a system.
The syntax may seem strange to us but users are unlikely to notice or
care as long as the URL can be emailed and pasted into a browser
address bar as this one can.
how identify parent and child route? for child route used /... for example say in your app.component file
@RouteConfig([
{ // Crisis Center child route
path: '/crisis-center/...',
name: 'CrisisCenter',
component: CrisisCenterComponent,
useAsDefault: true
},
// here heroes is parent/ route route
{path: '/heroes', name: 'Heroes', component: HeroListComponent}
])
See this example got to crisis center details and click on Cancel and go to heros details and click on Back to show different url
N.B: plunker view pop out the preview window by clicking the blue 'X' button in the upper right corner.