In our angular-cli generated app we have one module called app.module.ts inside the app dir. So whats the use of this, as in the previous post we said that this is used to bootstrap the component but lets examine this line by line what all other stuffs it can do
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
- At first we are importing all the modules that are used in our app
- BrowserModule : registers critical application service providers. It also includes common directives like
NgIf
andNgFor
which become immediately visible and usable in any of this modules component templates. - NgModule: This module is used to import angular core Module lib
- FormsModule: This module is used to handle the input related tasks
- HttpModule: This mdule is used to make http services available in our module
- @NgModule : It is imported from angular/core. Here we tell angular what is used in our app.
- declaration: What directives we have used in our app, Components are directives. It basically tells which componets should I use through out my application.
- imports: which other modules should I use. like browser module is used to use other default directives.
- providers: is used if we want to have application wise services
- bootstrap: it is used to bootstrap the components that is used in this module
- The export keyword enable out module to be used externally
Thats all for now. In the next session we will talk about the templates \m/
thanks for sharing this information
ReplyDeletebest python training in chennai
best python training in sholinganallur
best python training institute in omr
python training in omr
best java training in chennai
devops training in chennai
best devops training in chennai
Highly informative article. I was searching for such quality articles for a long time. I am happy that I found this article. Keep going!
ReplyDeleteData Science Course in Chennai | Data Science Training in Chennai