Why does Angular 2 name a module NgModule and not just Module

170 Views Asked by At

So in Angular 2, a lot of things improved compared to Angular1 (AngularJS). I'm really happy with it. But what confuses me the most is the in my opinion inconsistent naming:

Component: @Component
Module: @NgModule

Why would the module be prefixed with Ng, when the component is not? Is there any reason for this inconsistent naming?

2

There are 2 best solutions below

2
On BEST ANSWER

Module is quite overloaded (ES6 modules) for example. There is a lot of confusion about TypeScript imports and @NgModule({imports: [...]}) for example.

They just wanted to make it clear what this module concept is about. Component is much more unlikely to be confused when Angular is used.

0
On

Starting with ECMAScript 2015, JavaScript has a concept of modules. TypeScript shares this concept.

Modules (TypeScript)

Modules are an already existing concept in TypeScript and ECMAScript. They probably didn't want to introduce a double meaning for "Module".