What are Modules (@NgModule decorator) in angular?

997    Asked by RickNovak in Python , Asked on Jan 2, 2020
Answered by Rick Novak

The NgModule is a TypeScript class marked by the @NgModule decorator.

Implementing the NgModule decorator to classify a class as an Angular Module. The Angular module helps us to organize an application into associative blocks of functionality.

An angular module signifies a core concept and plays an important role in structuring Angular applications. The NgModule is utilized for simplifying the ways we express and manage the dependencies in our applications and also we could consolidate different components and services into associative blocks of functionality. The purpose of the module is to declare everything we create in Angular and group them together.

Given example specifying an NgModule:

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

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

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

import { LoginComponent } from './login/login.component';

//AppModule class with @NgModule decorator.

@NgModule({

  declarations: [

    AppComponent,

    LoginComponent

  ],

  imports: [

    BrowserModule

  ],

  providers: [],

  bootstrap: [AppComponent]

})

export class AppModule { }



Your Answer

Interviews

Parent Categories