Lazy loading

Now that you understand how eager-loading of modules work, you will be able to better understand the code we are about to write, which may otherwise seem like black-magic, and magical (aka misunderstood) code always leads to spaghetti architectures.

We will now evolve the eager-loading solution to be a lazy-loading one. In order to load routes from a different module, we know we can't simply import them, otherwise they will be eagerly loaded. The answer lies in configuring a route using the loadChildren attribute with string informing the Router how to load a submodule in app-routing.module.ts:

  1. Ensure that any module you intend to lazy load is not imported in app.module

  1. Remove any routes added to ManagerModule
  2. Ensure that ...

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.