【发布时间】:2017-10-27 22:02:17
【问题描述】:
我必须在主模块和功能模块中都使用路由。 当我将路由器导入功能模块时,应用程序不起作用,浏览器正在“思考”并保持加载,直到 chrome 显示“页面没有响应”。
我跟随但没有成功 this answer
应用路由:
const appRoutes: Routes = [
{ path: 'login', component: AuthComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'resetpassword', component: ResetPassword },
{ path: 'resetpassword/choose', component: ChoosePassword },
{ path: 'tournament', component: Tournament },
{ path: '', component: HomeComponent, pathMatch: 'full', canActivate: [AuthGuard] },
{ path: '**', redirectTo: '' }
];
export const routing = RouterModule.forRoot(appRoutes);
以及功能模块中的路线:
const appRoutes: Routes = [
{
path: 'tournament', component: Tournament, children:
[
{ path: 'new', component: TournamentCreationMain },
]
},
{ path: '', component: Tournament, pathMatch: 'full', canActivate: [AuthGuard] },
{ path: '**', redirectTo: '' }
];
export const routingTournament = RouterModule.forChild(appRoutes);
在 app.module 中,我导入功能模块和 app.router:
imports: [
BrowserModule,
FormsModule,
HttpModule,
TournamentModule,
routing
]
在功能模块中我导入了自己的路由器:
imports: [
CommonModule,
FormsModule,
routingTournament,
HttpModule
]
提前致谢 最大
【问题讨论】: