2016-07-06 133 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