1 app.module.ts
/* Angular的核心模块 */import { NgModule } from '@angular/core';/* 浏览器解析模块 */import { BrowserModule } from '@angular/platform-browser';/* App组件 */import { AppComponent } from './app.component';/* http请求模块 */import {HttpClientModule} from '@angular/common/http'@NgModule({/* (配置)声明当前项目运行依赖的组件 */declarations: [AppComponent],/* 配置当前项目运行依赖的其他模块 */imports: [BrowserModule,HttpClientModule],/* 配置项目所需要的服务 */providers: [],/* 指定应用的主视图 */bootstrap: [AppComponent]})/* 通过导出AppModule这个模块,来启动应用 */export class AppModule { }
2 组件
A.app.component.ts
import { Component } from '@angular/core';@Component({selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']})export class AppComponent {title = 'my-app';}
B.app.component.html
<div>hello world</div>
