我似乎在Angular 2的新路由器3.0.0-alpha.8中遇到問題。Angular 2路由器3.0.0嵌套路由編譯
長話短說,我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
];
它負載部分路由就好這就是:
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當路由嵌套。我很想對如何繼續,因爲我是相當丟失:(
感謝!
EXTRA信息任何幫助或想法: 我main.ts有:
bootstrap(AppComponent, [
...
APP_ROUTER_PROVIDERS,
]
中─ A-多個路線是這樣的:
export const SectionARoutes: RouterConfig = [
{ path: '', component: SectionAMoreListComponent, canActivate: [AuthGuard] },
{ path: '/:id', component: SectionAMoreDetailComponent, canActivate: [AuthGuard] }
];
TLDR:爲什麼我的嵌套航線角2和路由器編譯3.0.0
你有什麼作爲你的基礎href在index.html中? –