+1 vote
in Angular by

What is a module?

1 Answer

0 votes
by
Modules are logical boundaries in your application and the application is divided into separate modules to separate the functionality of your application. Lets take an example of app.module.ts root module declared with @NgModule decorator as below,

import { NgModule }      from '@angular/core';

import { BrowserModule } from '@angular/platform-browser';

import { AppComponent }  from './app.component';

@NgModule ({

   imports:      [ BrowserModule ],

   declarations: [ AppComponent ],

   bootstrap:    [ AppComponent ],

   providers: []

})

export class AppModule { }

The NgModule decorator has five important (among all) options:

The imports option is used to import other dependent modules. The BrowserModule is required by default for any web based angular application.

The declarations option is used to define components in the respective module.

The bootstrap option tells Angular which Component to bootstrap in the application.

The providers option is used to configure a set of injectable objects that are available in the injector of this module.

The entryComponents option is a set of components dynamically loaded into the view.
...