Kondas Lamar Jnr
Kondas Lamar Jnr

Reputation: 143

Angular Lazy loading strategy

I have a angular 6 project working on with about 15 pages and i want implement angular lazy loading, through my research i got bit confused .

My questions is do i have to create module file for each component or just one module file for all the component im applying the lazy loading and with in an easy step !! Any help here

enter image description here

Upvotes: 1

Views: 440

Answers (1)

Gurvinder Guraya
Gurvinder Guraya

Reputation: 669

Lazy loaded module can have one or more components inside it. But the module which you are going to lazy load needs to be a different module then your root module

So in your case if you want to lazy load every single component for each route you have to create a module file for each component

For example if you are trying to lazyload your dashboard component on route Dashboard then you have to create a Dashboard module with all the components it need

You can have a look here for more info https://angular-2-training-book.rangle.io/handout/modules/lazy-loading-module.html

Let me know if this answers your question

Upvotes: 1

Related Questions