Separating our app into feature routing modules
At this point, we have set up the route configuration so that routing works the way it should. However, this approach doesn't scale so well. As our application grows, more and more routes may be added to AppRoutingModule
. Thus, we should create a separate feature module for our components that will also have a dedicated routing module.
We have already learned how to create a new Angular module in Chapter 5, Structure an Angular App. We will use the same generate
Angular CLI command, but we will pass a different option to create the routing module as well:
ng generate module heroes --routing
The --routing
parameter instructs the Angular CLI to create a routing module along with the heroes
feature module:
The Angular CLI names the routing module file after the name of the actual feature module, appending the -routing
suffix. This is a convention...