【发布时间】:2019-10-27 17:53:00
【问题描述】:
我有一个 Angular 应用程序,其中根目录是可变路由参数:
/:demo_profile/(etc).
我不能使用相对路径,因为我的 routerLink 可从不同的组件/路由获得。
如何设置一个相对于我的站点根目录的routerLink 目标,然后是这个参数?即
/SomeRoute/home
我的路线:
const routes: Routes = [
{
path: ':demo_profile',
children: [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent,
},
{
path: 'cards',
component: CardsComponent,
},
{
path: 'card/:id',
component: CardComponent,
},
{
path: 'help',
component: HelpComponent,
},
{
path: '**',
redirectTo: ':demo_profile',
}
]
},
{
path: '\**',
redirectTo: '/DGInsureCo/home',
}
];
【问题讨论】:
标签: angular router angular-routerlink