Sitemap

Practical Guide: Angular Lazy Loading Key Points

Mar 25, 2021
Press enter or click to view image in full size

To know anything essential like WHY, WHAT and HOW, please read the document from Angular official site:

Here just summarize some key points for experienced developers to start immediately.

  • In the file of app-routing.module.ts of every lazy-loading module, use forChild() but not forRoot()
  • In the file of app-routing.module.ts of the root module, use loadChildren() but not XxxComponent
  • In the file of app.module.ts of the root module, remove all the lazy-loading modules from “imports” list. Otherwise, lazy loading won’t work!

--

--

Derek Ji
Derek Ji

Written by Derek Ji

Full Stack Developer (.NET | Angular)

No responses yet