Angular NgModule Metadata

Angular NgModule Metadata

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.

An Angular 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.

  • declarations—The components, directives, and pipes that belong to this NgModule.
  • exports—The subset of declarations that should be visible and usable in the component templates of other NgModules.
  • imports—Other modules whose exported classes are needed by component templates declared in this NgModule.
  • providers—Creators of services that this NgModule contributes to the global collection of services; they become accessible in all parts of the app. (You can also specify providers at the component level, which is often preferred.)
  • bootstrap—The main application view, called the root component, which hosts all other app views. Only the root NgModule should set this bootstrap property.

 

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

Angular 4 Tutorial IndexBack to Angular 4 Tutorial Main Page

Angular Feature Modules
Angular NgModules and Components

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?