aweber-banner

How to create a lazy-loaded module and its feature component with just one command

In this guide, we will learn how to create a lazy-loaded module and its feature component with just one command


We can do this directly in the terminal using the following command:


ng g m course — module app — routing true — route course



The above command will do the following things:

  • A folder with the course name is created
  • The course component is created inside it
  • Course module has been created with course component declaration
  • Course routing module has been created with course component route

Also, the app routing module has been updated with a lazy loaded route to your new course module.

{ path: 'course', loadChildren: () => import('./course/course.module').then(m => m.CourseModule) }

This one line of command does a lot for you and makes it so much easier when you work with Angular.