Feature modules and lazily loaded routes
In the previous recipe, we learned how to create a basic routing app with eagerly loaded routes. In this recipe, you'll learn how to work with feature modules to lazily load them instead of loading them when the app loads. For this recipe, we'll assume that we already have the routes in place and we just need to load them lazily.
Getting ready
The project for this recipe resides in chapter07/start_here/lazy-loading-modules
:
- Open the project in Visual Studio Code.
- Open the terminal and run
npm install
to install the dependencies of the project. - Once done, run
ng serve -o
.This should open the app in a new browser tab and you should see the app as follows:
Now that we have the app running locally, let's see the steps of the recipe in the next section.
How to do it…
As shown in Figure 7...