【发布时间】:2018-11-10 01:12:34
【问题描述】:
您好,我遇到了一个问题,因为我有一个包含“&”字符的路由参数。这是我的路线配置:
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'work', component: WorkComponent},
{path: 'who', component: WhoComponent},
{path: 'process', component: ProcessComponent},
{path: 'services', component: ServicesComponent},
{path: 'project/:name', component: ProjectComponent}
];
这是我的链接:
<button class="some-class" [routerLink]="'/project/R&D more text here'">R&D Things and stuff</button>
第一次点击链接时一切正常,正确的路由被激活,名称路由参数获得完整的字符串值。问题出在页面刷新上,路由器将 url 更改为:
http://localhost:4200/project/R
处理此路由问题的最佳方法是什么?
【问题讨论】:
标签: angular angular-routing angular-router