1 app.module.ts

  1. /* Angular的核心模块 */
  2. import { NgModule } from '@angular/core';
  3. /* 浏览器解析模块 */
  4. import { BrowserModule } from '@angular/platform-browser';
  5. /* App组件 */
  6. import { AppComponent } from './app.component';
  7. /* http请求模块 */
  8. import {HttpClientModule} from '@angular/common/http'
  9. @NgModule({
  10. /* (配置)声明当前项目运行依赖的组件 */
  11. declarations: [
  12. AppComponent
  13. ],
  14. /* 配置当前项目运行依赖的其他模块 */
  15. imports: [
  16. BrowserModule,
  17. HttpClientModule
  18. ],
  19. /* 配置项目所需要的服务 */
  20. providers: [],
  21. /* 指定应用的主视图 */
  22. bootstrap: [AppComponent]
  23. })
  24. /* 通过导出AppModule这个模块,来启动应用 */
  25. export class AppModule { }

2 组件

A.app.component.ts

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'app-root',
  4. templateUrl: './app.component.html',
  5. styleUrls: ['./app.component.css']
  6. })
  7. export class AppComponent {
  8. title = 'my-app';
  9. }

B.app.component.html

  1. <div>hello world</div>