I think you should use a router inside Angular2. Code example:
import {Component} from 'angular2/core'; import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; import {ProfileComponent} from './profile.component'; @Component({ selector: 'my-app', template: ` <router-outlet></router-outlet> `, directives: [ROUTER_DIRECTIVES] }) @RouteConfig([ {path: '/profile/:id', name: 'Profile', component: ProfileComponent} ]) export class AppComponent { }
Parameter: id is the route parameter, and you can make such a URL: / profile / 2 and 2 is the value of the id parameter.
More information can be found in the Angular2 doc document: router doc
source share