Reputation: 3678
I am trying to learn lazy loading in angular 4 .I took help from this tutorial
How to Lazy Load Components in Angular 4 in Three Steps
using loadchildren
I tried to implement this in my example.My application is working fine but lazy load is not working .
I have four tab on header (first, second , third ,fourth) .When I click on third
or fourth
I didn't find any extra network
to load module
here is my code
const appRoutes: Routes = [
{ path: 'first', component: FirstComponent },
{ path: 'second', component: SecondComponent },
{ path: 'seo', loadChildren: '../foo/foo.module#FooModule'},
{ path: '',redirectTo: '/first',pathMatch: 'full'}
];
@NgModule({
imports: [ BrowserModule, FormsModule ,RouterModule.forRoot(appRoutes)],
declarations: [ AppComponent,FirstComponent,SecondComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
What I'm doing wrong?
Upvotes: 1
Views: 316
Reputation: 1254
Your code is not wrong, I tested with localhost and it renders as expected. I think stackblitz has a different way to deal with lazy loading.
stackblitz's issue
Upvotes: 1