2017-06-27 204 views
1

我有兩個模塊,我加載這些模塊與延遲加載。懶加載模塊不加載模塊js文件

  1. 的AppModule
  2. PassangerModule

的AppModule被定義爲跟隨

@NgModule({ 
    imports: [ 
     BrowserModule, 
     FormsModule, 
     HttpModule, 
     CabModule, 
     RouterModule.forRoot([ 
      { path: '', component: CabComponent }, 
      { path: 'Cabs', component: CabComponent }, 
      { path: 'Passanger', loadChildren: 'App/Passanger/passanger.module#PassangerModule' } 
     ]) 
    ], 
    declarations: [ 
     AppComponent, 
     CabComponent, 
     CabFilterPipe, 
     CabAddComponent 
    ], 
    bootstrap: [AppComponent], 
    providers: [ 
     CabService 
    ] 
}) 
export class AppModule { } 

和ProductModule定義如下:當我瀏覽到/產品

@NgModule({ 
    imports: [ 
     CommonModule, 
     RouterModule.forChild([ 
      { 
       path: '', component: PassangerComponent 
      } 
     ]) 
    ], 
    declarations: [ 
     PassangerComponent 
    ], 
    providers: [ 
     PassangerService 
    ] 
}) 
export class PassangerModule { 
} 

現在它不工作,嘗試對http://localhost:3000/App/Passanger/passanger.module GET請求是無效的路徑,而不是它應該passanger.module.js

我檢查了一倍,這是有defaultExtension在systemjs.config.js

回答

1

JS申請得到我改變了路線模塊路徑,並使App/...以小寫app/...,它的工作。

我不知道爲什麼該字符串區分大小寫,但它對我有用。

RouterModule.forRoot([ 
      { path: '', component: CabComponent }, 
      { path: 'Cabs', component: CabComponent }, 
      { path: 'Passanger', loadChildren: 'app/Passanger/passanger.module#PassangerModule' } 
     ]) 
+0

有趣!所以它看起來像路徑區分大小寫,然後 –

+0

@FredrikLundin文件夾名稱是'App'而不是'app'。不知道爲什麼,但只能使用小寫名稱。 –

+0

此tsconfig.json的原因有選項 --forceConsistentCasingInFileNames by defaulse false。你可以點擊下面的鏈接 http://www.typescriptlang.org/docs/handbook/compiler-options.html –