Site icon Tutorial

Angular NgModule API

Angular NgModule API

Angular NgModules configure the injector and the compiler and help organize related things together.

An NgModule is a class marked by the @NgModule decorator. @NgModule takes a metadata object that describes how to compile a component’s template and how to create an injector at runtime. It identifies the module’s own components, directives, and pipes, making some of them public, through the exports property, so that external components can use them. @NgModule can also add service providers to the application dependency injectors.

At a high level, NgModules are a way to organize Angular apps and they accomplish this through the metadata in the @NgModule decorator. The metadata falls into three categories:

 

 

@NgModule({

// Static, that is compiler configuration

declarations: [], // Configure the selectors

entryComponents: [], // Generate the host factory

 

// Runtime, or injector configuration

providers: [], // Runtime injector configuration

 

// Composability / Grouping

imports: [], // composing NgModules together

exports: [] // making NgModules available to other parts of the app

})

 

@NgModule metadata

IT Professionals, Web Developers, Web Programmers, IT students can Apply for the certification course to move ahead in their careers.

Back to Angular 4 Tutorial Main Page

Exit mobile version