Generate and Lazy Load the PostsModule
We will generate the PostsModule
using the ng
command and lazy load the PostsModule
in the AppRoutingModule
.
Using the ng generate
command, we can generate or scaffold out all sorts of code that can be used in our Angular application.
We will use the ng generate module
command to generate our PostsModule
.
This command has one required parameter, which is the name. In our application, we will call this module posts
. A second optional parameter is passed in in order to create a separate file to hold the routes for this module, the PostsRoutingModule
:
- Open your terminal and navigate to the project directory.
- Run the following command from inside the project directory:
ng g m posts --routing
As you can see from the ...
Get Beginning Server-Side Application Development with Angular 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.