DEV Community

Deepa Chaurasia
Deepa Chaurasia

Posted on

5 1

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more