What are Modules in Angular?

deepachaurasia1

Deepa Chaurasia

Posted on March 16, 2022

What are Modules in Angular?

Angular doesn't scan automatically all your components and services .
You have to tell Angular what all component, service,directives you have or you are using

Modules does that for you.
Every Angular app must have at least one module (i.e.AppModule)

Modules are basically a place in angular where you group together your components,directives,services etc.

Image description

Here you can see appModule.

1. @NgModule-
Angular analyzes ngModules to understand application and it's features.You can't use a feature without including it in @NgModule.

2.Imports-
Imports are important to import other modules into our module like FormsModule,RoutingModule etc.We cannot add every single feature from nodemodule so we import collectively a whole module which contain most of it.

3.Providers
_It defines all services we are providing in our angular app.All the services declared in angular must be inside the _providers of AppModule.

Or you have one other method if you don't wanna write in providers

Image description

you have to use
@Injectable({
providedIn: 'root'
})

4. Bootstrap[]
Bootstrap is important for starting your app.It defines which component is available straight in your app **(i.e app-root) **at first.
You can include other components also that's why it's array . But it is not likely to add other component other than AppComponent.

💖 💪 🙅 🚩
deepachaurasia1
Deepa Chaurasia

Posted on March 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Angular: Binding end to end
javascript Angular: Binding end to end

August 9, 2022

PIPES IN ANGULAR 11
javascript PIPES IN ANGULAR 11

April 12, 2022

What are Modules in Angular?
javascript What are Modules in Angular?

March 16, 2022

Angular Developer Roadmap
angular Angular Developer Roadmap

October 18, 2021