1
我有兩個模塊,我加載這些模塊與延遲加載。懶加載模塊不加載模塊js文件
- 的AppModule
- 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
有趣!所以它看起來像路徑區分大小寫,然後 –
@FredrikLundin文件夾名稱是'App'而不是'app'。不知道爲什麼,但只能使用小寫名稱。 –
此tsconfig.json的原因有選項 --forceConsistentCasingInFileNames by defaulse false。你可以點擊下面的鏈接 http://www.typescriptlang.org/docs/handbook/compiler-options.html –