【发布时间】:2018-06-15 14:53:36
【问题描述】:
我有一个路由模块如下:
应用路由模块
const routes: Routes = [
{
path: '',
redirectTo: environment.devRedirect,
pathMatch: 'full',
canActivate: [AuthenticationGuard]
},
{
path: 'customers/:customerId/contracts/:contractId',
loadChildren: './grouping/grouping-routing.module#GroupingRoutingModule'
canActivate: [AuthenticationGuard],
}
];
还有一个带有路由的子组件:
const routes: Routes = [
{
path: 'create',
component: CreateEditComponent,
data: { animation: 'create' },
canActivate: [ AuthenticationGuard ]
},
{
path: ':groupId/edit',
component: CreateEditComponent,
data: { animation: 'edit' },
canActivate: [ AuthenticationGuard ]
},
{
path: '',
component: OverviewComponent,
data: { animation: 'overview' },
canActivate: [ AuthenticationGuard ]
}
];
我有一个顶级导航栏组件,它位于 app.component.html 中。
导航栏组件和 CreateEditComponent 都有一个如下所示的函数。两者都使用带有(单击)的按钮调用:
goToOverview(): void {
this._router.navigate(['customers/:customerId/contracts/:contractId']);
}
当我调试路由器对象时,它们看起来完全一样,即具有所有相同的路径等。
我的问题是导航栏功能正确路由,但 CreateEditComponent 导航,附加一个?然后重新加载页面。我在这里遗漏了什么,为什么当 activateRoute 对象相同时,两个看似相似的调用会产生如此不同的结果?
【问题讨论】:
标签: angular typescript angular-router