我在了解Angular路由器行为时遇到问题。当前,路由模块如下所示:
const routes: Routes = [
{
path: '',
component: ManageCompetitionComponent,
children: [
{
path: ':eventID',
component: EventProfileComponent,
},
],
}];
当我打开http://localhost:4200/admin/competition
并单击导航到http://localhost:4200/admin/competition/1234
的链接时,它工作正常,并且EventProfileComponent
显示为ManageCompetitionComponent
的一部分(包含路由器出口)
但是当我现在从浏览器拨打电话时(例如,refresh / F5):
http://localhost:4200/admin/competition -> works fine
http://localhost:4200/admin/competition/1234 -> redirects to /admin/competition
那么我该如何防止重定向?
答案 0 :(得分:0)
尝试一下
const routes: Routes = [
{
path: '',
component: ManageCompetitionComponent,
},
{
path: ':eventID',
component: EventProfileComponent,
}];