一个简单的模块
模块是一个带有 @NgModule 装饰器的类。要创建模块,我们添加 @NgModule 传递一些参数:
bootstrap:将成为应用程序根目录的组件。此配置仅存在于根模块上declarations:模块声明的资源。添加新组件时,你必须更新声明(ng generate component会自动执行)exports:资源可以在其他模块中使用的模块导出imports:模块从其他模块使用的资源(仅接受模块类)providers:可以在组件中注入(di)的资源
一个简单的例子:
import { AppComponent } from './app.component';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
@NgModule({
bootstrap: [AppComponent]
declarations: [AppComponent],
exports: [],
imports: [BrowserModule],
providers: [],
})
export class AppModule { }