Angular Js

How to Create a New Module in Angular?

How to Create a New Module in Angular?

Create a New Module in Angular

The most crucial component of an Angular application is the NgModule. They assist in the creation of independent modules, which can then be loaded when needed via the router's lazy loading method.
Every Angular application has at least contains one NgModule class, the root module in angular known as AppModule, and resides in app.module.ts. The application launched by bootstrapping the root NgModule(AppModule). Most applications would have much more NgModule aka feature modules. The root NgModule includes all child NgModules in a hierarchy of any depth.


Step1: Creating a Module
Generate NgModule Using CLI

ng generate module home
# OR
ng g m home

It generates HomeModule inside home folder


Step2: Creating EmployeeLogin Component within Employee module folder
Here, we need to create the component within the Home folder.

ng g c Home/UserLogin

It create the UserLogin component within the Home folder


Step3: Adding UserLogin component reference in Home module
this work is automatically done by the angular framework for us. If you open the home.module.ts file, then you will see that the import and declarations sections are automatically done




Related Post

About Us

Community of IT Professionals

A Complete IT knowledgebase for any kind of Software Language, Development, Programming, Coding, Designing, Networking, Hardware and Digital Marketing.

Instagram