Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Beginning Server-Side Application Development with Angular

You're reading from   Beginning Server-Side Application Development with Angular Discover how to rapidly prototype SEO-friendly web applications with Angular Universal

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher
ISBN-13 9781789342161
Length 110 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bram Borggreve Bram Borggreve
Author Profile Icon Bram Borggreve
Bram Borggreve
Arrow right icon
View More author details
Toc

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:

  1. Open your terminal and navigate to the project directory.

  2. Run the following command from inside the project directory:

    ng g m posts --routing

As you can see from the output of the command, our PostsModule is generated in the new folder src/app/posts:

In contrast to how we load our UiModule by importing it into our AppModule, we will lazy load our PostsModule using our AppRoutingModule.

This is an optimization of how...

You have been reading a chapter from
Beginning Server-Side Application Development with Angular
Published in: Apr 2018
Publisher:
ISBN-13: 9781789342161
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image