Jenish Rabadiya
Jenish Rabadiya

Reputation: 6766

lazy loading module does not load module js file

I have two Modules that i am loading those modules with lazy loading.

  1. AppModule
  2. PassangerModule

AppModule is defined as follow

@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 { }

and ProductModule is defined as follow:

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

Now when I navigated to /Products it does not work and tries GET request on http://localhost:3000/App/Passanger/passanger.module which is not valid path instead it should apply GET on passanger.module.js

I doubled checked that it is having defaultExtension as js in systemjs.config.js

Upvotes: 1

Views: 136

Answers (1)

Jenish Rabadiya
Jenish Rabadiya

Reputation: 6766

I changed the route module path and make App/... to lower case app/... and it worked.

I don't know why that string is case sensitive but it worked for me.

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

Upvotes: 1

Related Questions