1 新建项目
ng new
2 项目结构
(1)src目录下,index.html是项目入口
(2)在app目录下新建component,新建以后得到:
- 一个.component.ts文件
- 一个.component.spec.ts文件
- 一个.component.css文件
- 一个.component.html文件
.component.ts定义了这个component的逻辑,@component一般包含三部分:
- seletor
- templateURL
- css
新建的componet可以在src目录外的.app文件(相当于程序入口)中引用。
3 启动服务器
ng serve
ng serve --port 可以指定端口
4 *ngFor
例如<li *ngFor = "let elem of elems" > Hi {{elem}} </li>
5 @Input()
用来输入数据
6 @NgModule
- declarations
- imports
- providers
- bootstrap