为什么我们不必导入NgModule?

时间:2018-03-23 11:01:29

标签: angular

我正在关注Angular Tutorial HERE

On Imports,我们引入以下内容:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'

在@NgModule中,我们只导入BrowserModule& FormsModule。

imports: [
    BrowserModule,
    FormsModule
],

为什么我们不在NgModel中导入?这是因为它是Angular Core Library的一部分吗?

3 个答案:

答案 0 :(得分:2)

NgModel指令包含在FormsModule

https://angular.io/api/forms/NgModel

您在应用中导入它就足以让它可用。

答案 1 :(得分:0)

来自angular 4 docs:

您必须导入:

|                value |
|----------------------|
| 2018-03-23T11:12:00Z |

答案 2 :(得分:0)

角度有自己的模块系统。 Angulat处理它的部分称为“ NgModule” 创建模块时需要将其导入。但是您不需要将其导入模块中...您只需使用它来创建模块。 因为您在导入或导出部分看不到NgModule。 阅读doc

相关问题