angular

What is Ng Modules, Declarations, Imports, Exports, Entry Components and Feature Modules in Angular

What is Ng Modules, Declarations, Imports, Exports, Entry Components and Feature Modules in Angular

In this tutorail, we will learn about ngModules in angular.

NgModules or Modules are basically building block on angular applications.

Angular libraires such as RouterModule, HttpClientModule and FormsModule are NgModules.

Each Angular Application must have  one root  module which is called AppModule

We can also use third party libraries like Materail design which are avaible as NgModules.

NgModules consolidate components,directives and pipes into one block.

In Angular, every component, module, directives or pipes is basicallt class.

So, basically, ngModule is a class marked by the @NgModule decorator

Declaration:

Decalration declares components, directives, and pipes.

Decalration are to  make components,directives, pipes from the current module avialble to other directives in the current module.

Imports:

Imports makes the exported declaration of other modules avaiavle in current module 

Exports:

Exports modules used when we are going to use diffrent feature modules, suppose we have large application which have many modules like admin modules, user module, so in this case instead of having one root module, we can have seprated module for every features

Now imagine a scenerio where we have one method in user module which we want to use in admin module, then we need to use exports for decalring component,pipes or directives

So, bascially exports usefull for cross communication between the modules

Providers:

Providers is basically used for injecting services, so whenever we need to use any services in entire app we can inject it to root module inside providers

Bootstrap:

Bootstrap atribute basically when our application load first time then we need to provide first component or root component, 

EntryComponents:

An entry compinent is any component that  Angular loads imperatively, means you're not refrecning it in the template by type

EntryComponents are basically those component which are used by routing 

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment