1

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

enter image description here

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?

1
  • Did you notice additional chunks when bundling your app ? (They should not be marked as [initial]) Commented May 28, 2018 at 10:01

1 Answer 1

1

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 enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

will it load foo-module on both cases when user click on third and forth tab
@user5711656 it will load only first time when user click third or forth tab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.