<a [routerLink]="['/R1',{para:value}]">
创建
之类的链接/link/route1/?para=value
我如何获得
/link/route1/para/value
出了一个标签?
答案 0 :(得分:2)
在路线配置的路径中声明交配参数
@Component({
selector: 'my-app',
directives: [ROUTER_DIRECTIVES],
template: `
<h2>Hello</h2>
<a [routerLink]="['/Form']">Form</a>
<a [routerLink]="['/Other', {para:'xxx'}]">Other</a>
<router-outlet></router-outlet>
`
})
@RouteConfig([
{path: '/form', name: 'Form', component: HeroFormComponent, useAsDefault: true},
{path: '/other/:para', name: 'Other', component: OtherComponent, }
])
export class App {
}