命令行:
命令行 | 含义 | 简写 |
---|---|---|
ng new 包名 | 生成项目包 | ng n 包名 |
ng serve | 启动项目, 端口号4200 | ng s |
ng serve --open | 启动项目 并 在默认浏览器自动打开 | ng s -o |
ng generate component 组件名 | 生成组件 | ng g c 组件名 |
ng generate directive 指令名 | 生成指令 | ng g d 指令名 |
ng generate pipe 管道名 | 生成管道 | ng g p 管道名 |
指令:
指令 | 用法 |
---|---|
{{}} | 同 vue, 小程序. 在 html中书写js 代码 |
[innerHTML] | 显示 html 代码 |
*ngFor=“let item of items; let i=index” | for循环 |
*ngIf="" | if判断 |
[(ngModel)] | 双向数据绑定 注意事项: 必须手动挂载 Forms 模块 |
[ngStyle]="{样式名: 值, 样式名: 值…}" | 动态 style |
[ngClass]="{样式类名: true/false}" | 动态 class |
{{ 值 | 管道名 : 参数 : 参数… }} | 管道, pipe; 对应vue中的 filter |