gpt4 book ai didi

javascript - 重新加载Angular子组件将用户带到localhost:4200

转载 作者:行者123 更新时间:2023-12-03 16:59:27 25 4
gpt4 key购买 nike

在我的Angular应用程序中,我有一些子组件,这些子组件可能带有路线参数。我可以轻松地从父级重定向到这些子级组件,但是当我重新加载子级组件时,应用程序导航到localhost:4200并给出如下的路由错误。

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'project-setup/project-setup-steppers'

这是我的路由配置:
const routes: Routes = [
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthenticationGuardService] },
{ path: 'project-setup', component: ProjectSetupComponent, canActivate: [AuthenticationGuardService] ,
children: [
{
path: 'project-setup-steppers/:projectId',
component: ProjectSetupSteppersComponent,
canActivate: [AuthenticationGuardService]
},
{
path: 'selfs', component: SelfsComponent, canActivate: [AuthenticationGuardService],
children: [
{
path: 'raters/:selfUserId/:formSetUpKey',
component: RatersComponent, canActivate: [AuthenticationGuardService]
}
]
},
]},
{ path: 'participant-setup', component: ParticipantSetupComponent, canActivate: [AuthenticationGuardService] },
{ path: 'launch-and-status', component: LaunchStatusComponent, canActivate: [AuthenticationGuardService] },
{ path: 'launch-project-desc', component: LaunchProjectDescriptionComponent, canActivate: [AuthenticationGuardService] },
{ path: 'question-setup', component: QuestionSetupComponent, canActivate: [AuthenticationGuardService] },
{ path: 'email-setup', component: EmailSetupComponent, canActivate: [AuthenticationGuardService] },
{ path: 'participant-steppers', component: ParticipantSteppersComponent, canActivate: [AuthenticationGuardService], children: [] },
{
path: 'report-project-list', component: ReportProjectListComponent, canActivate: [AuthenticationGuardService],
children: [
{
path: 'report-project-detail-list/:projectId',
component: ReportProjectDetailListComponent, canActivate: [AuthenticationGuardService]
}
]
},

{ path: 'report-detail/:id/:type', component: ReportDetailComponent, canActivate: [AuthenticationGuardService] },
{ path: 'trial/:projectId', component: TrailRunProjectComponent, canActivate: [AuthenticationGuardService] },
{ path: 'status-of-project/:projectId', component: StatusOfProjectComponent, canActivate: [AuthenticationGuardService] },
{ path: 'project-status-details', component: ProjectStatusDetailsComponent, canActivate: [AuthenticationGuardService] },
{ path: 'news', component: NewsComponent, canActivate: [AuthenticationGuardService] },
{ path: 'view-responses/:assigneeId', component: ViewProjectResponsesComponent, canActivate: [AuthenticationGuardService] },
{ path: 'copy-project/:projectId', component: CopyProjectComponent, canActivate: [AuthenticationGuardService] }

];

我在父组件中使用嵌套的 router-outlet来呈现子组件。
即使用户从子组件重新加载应用程序,我也希望保持原样。

最佳答案

将此添加到您的应用路由文件

      ...
},
{
path: 'report-project-detail-list',
component: ReportProjectDetailListComponent, canActivate: [AuthenticationGuardService]
}

如果需要,必须定义带参数和不带参数的路线。

关于javascript - 重新加载Angular子组件将用户带到localhost:4200,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59897150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com