我有一种情况,如果子路由是一个参数,我想要一个解析器,而不是它是一个路径段。以下是我的代码。
{
path: 'agreement',
children: [
{
path: ':id',
component: AgreementComponent,
resolve: { agreementDetails: AgreementDetailsResolveService }
},
{
path: 'create',
component: AgreementComponent
}
]
}
当我点击路径agreement/create
时,它会抛出错误,因为create
被视为参数id
的值而且无效。
请帮助我。
答案 0 :(得分:1)
重新排列路线定义:
{
path: 'agreement',
children: [
{
path: 'create',
component: AgreementComponent
},
{
path: ':id',
component: AgreementComponent,
resolve: { agreementDetails: AgreementDetailsResolveService }
}
]
}