Site icon Tutorial

NgModule Metadata

Go back to Tutorial

An NgModule is defined as a class decorated with @NgModule. The @NgModule decorator is a function that takes a single metadata object, whose properties describe the module. The most important properties are as follows.

Here’s a simple root NgModule definition:

src/app/app.module.ts

import { NgModule }      from ‘@angular/core’;

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

@NgModule({

imports:      [ BrowserModule ],

providers:    [ Logger ],

declarations: [ AppComponent ],

exports:      [ AppComponent ],

bootstrap:    [ AppComponent ]

})

export class AppModule { }

The export of AppComponent is just to show how to export; it isn’t actually necessary in this example. A root NgModule has no reason to export anything because other modules don’t need to import the root NgModule.

Go back to Tutorial

Exit mobile version