我似乎对 Angular 2 的新路由器 3.0.0-alpha.8 有问题。
长话短说,我的 app.routes.ts 是
export const routes: RouterConfig = [
{ path: '', component: HomeComponent, canActivate: [AuthGuard] },
{ path: 'login', component: LoginComponent },
...SectionARoutes,
...SectionBRoutes
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes),
AUTH_PROVIDERS
];
它可以很好地加载 A 部分的路线,即:
export const SectionARoutes: RouterConfig = [
{ path: 'a', component: SectionAComponent, canActivate: [AuthGuard] },
{ path: 'a-more', component: SectionAMoreComponent, canActivate: [AuthGuard] },
...SectionAMoreRoutes
];
但它无法加载嵌套的 SectionAMoreRoutes。当我说加载失败时,我的意思是我得到的错误是:
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found)
loading http://localhost:4200/app/+a/+a-more/a-more.routes.ts.js(…)
嵌套路由时,我的打字稿似乎没有被编译成 js。我很想获得有关如何进行的任何帮助或想法,因为我迷路了:(
谢谢!!!
额外信息:我的 main.ts 有:
bootstrap(AppComponent, [
...
APP_ROUTER_PROVIDERS,
]
Section-a-more 路线如下所示:
export const SectionARoutes: RouterConfig = [
{ path: '', component: SectionAMoreListComponent, canActivate: [AuthGuard] },
{ path: '/:id', component: SectionAMoreDetailComponent, canActivate: [AuthGuard] }
];
TLDR:为什么我的嵌套路由不能在 Angular 2 和 Router 3.0.0 中编译