2016-07-06 128 views
0

我似乎在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

+1

你有什麼作爲你的基礎href在index.html中? –

回答

0

我想瘋了2天試圖找出這一點。

嘗試刪除app.routes.js文件(而不是TS FILE)

然後在命令行上輸入

TSC應用程序/ app.routes.ts

(或者你路由文件的地方)。

這應該重新編譯並創建一個新的app.route.js文件。

+0

謝謝。這是問題! – rgrambo