Short explanation of NgModule

Short explanation of NgModule

You started working with Angular a short time ago. You created your fist components or services. Then, inevitably, you saw weird messages at your browser console that looks confusing with long stack traces.

Like every other sane person, you go to the official documents. the trouble with the official documents for Angular though is they are written in a deep level. You can and will find yourself looking through page after page of deep explanations, while you only need some simple guidance. This post is that guidance.

Here’s a short explanation:

Imports – Makes the exported declarations of other modules available in the current module.

Declarations – Make components, pipes etc. available to other members of the same module.

Providers – Used for services that are used in a Dependency Injection context. So for example a class that has the @Injectable right above the class name, its most suitable placement location at ngModule is providers.

Exports – Makes the components, directives, and pipes available in modules that add this module to their imports.

Leave a Reply

Your email address will not be published. Required fields are marked *