1. // NgModule: Angular 模块装饰器
    2. import { NgModule } from '@angular/core';
    3. // BrowserModule 提供了启动和运行浏览器应用所必需的服务
    4. // CommonModule 提供各种服务和指令, 例如 ngIf 和 ngFor, 与平台无关
    5. // BrowserModule 导入了 CommonModule, 又重新导出了 CommonModule, 使其所有指令都可用于导入 BrowserModule 的任何模块
    6. import { BrowserModule } from '@angular/platform-browser';
    7. // 路由模块
    8. import { AppRoutingModule } from './app-routing.module';
    9. // 根组件
    10. import { AppComponent } from './app.component';
    11. // 调用 NgModule 装饰器, 告诉 Angular 当前类表示的是 Angular 模块
    12. @NgModule({
    13. // 声明当前模块拥有哪些组件
    14. declarations: [
    15. AppComponent
    16. ],
    17. // 声明当前模块依赖了哪些其他模块
    18. imports: [
    19. BrowserModule,
    20. AppRoutingModule
    21. ],
    22. // 声明服务的作用域, 数组中接收服务类, 表示该服务只能在当前模块的组件中使用
    23. providers: [],
    24. // 可引导组件, Angular 会在引导过程中把它加载到 DOM 中
    25. bootstrap: [AppComponent]
    26. })
    27. export class AppModule { }