为什么 Angular 2 将模块命名为 NgModule 而不仅仅是 Module
Why does Angular 2 name a module NgModule and not just Module
所以在 Angular 2 中,与 Angular1 (AngularJS) 相比,有很多改进。我真的很高兴。但最让我困惑的是在我看来不一致的命名:
组件:@Component
模块:@NgModule
为什么模块要以 Ng 为前缀,而组件不是?这种不一致的命名有什么原因吗?
例如,Module
非常重载(ES6 模块)。
关于 TypeScript 导入存在很多混淆,例如 @NgModule({imports: [...]})
。
他们只是想弄清楚这个模块的概念是什么。
当使用 Angular 时,Component
更不容易混淆。
Starting with ECMAScript 2015, JavaScript has a concept of modules. TypeScript shares this concept.
模块是 TypeScript 和 ECMAScript 中已经存在的概念。他们可能不想为 "Module".
引入双重含义
所以在 Angular 2 中,与 Angular1 (AngularJS) 相比,有很多改进。我真的很高兴。但最让我困惑的是在我看来不一致的命名:
组件:@Component
模块:@NgModule
为什么模块要以 Ng 为前缀,而组件不是?这种不一致的命名有什么原因吗?
Module
非常重载(ES6 模块)。
关于 TypeScript 导入存在很多混淆,例如 @NgModule({imports: [...]})
。
他们只是想弄清楚这个模块的概念是什么。
当使用 Angular 时,Component
更不容易混淆。
Starting with ECMAScript 2015, JavaScript has a concept of modules. TypeScript shares this concept.
模块是 TypeScript 和 ECMAScript 中已经存在的概念。他们可能不想为 "Module".
引入双重含义