Understand frequently used angular modules (NgModule) and their fields of application in the development of angular applications

Understand frequently used angular modules (NgModule) and their scope in the development of angular applications.

NgModule in Angular is the first basic structure you encounter when developing an application with Angular, but don’t forget that it is also the most subtle and complex, due to its different scopes. Speaking of understanding the frequently used angular modules (NgModule) and their scopes in the development of angular applications, the angular documentation has done a whole FAQ on NgModules, but it’s still quite complex, so we’re trying to simplify things here.

 

Why NgModule?

This is done automatically with Angular CLI, but the first thing you need to do in Angular is to load a root NgModule:

Talking about understanding frequently used angular modules (NgModule) and their scope in the development of angular applications, the purpose of a NgModule in Angular is to declare everything you create in Angular and to group them (like packages Java or PHP / C # namespaces).

Let’s review the frequently used angular modules (NgModule):

 

  • BrowserModule

Import it from: – @ angular / platform-browser

To be used for: – BrowserModule provides essential services for launching and executing a browser application.

 

  • CommonModule

Import it from: – @ angular / common

Use for: – When you want to use NgIf, NgFor

 

  • FormsModule

Import it from: – @ angular / forms

Use for: – Angular 1 tackles shapes via the famous ng-model directive.

 

Angular 2 now provides an identical mechanism also called ngModel, which allows us to create what are now called model-driven forms. Unlike AngularJs, ngModel and other form-related directives are not available by default

Leave A Comment

Whatsapp Whatsapp Skype