
创建组件
- 定义
hello.component.ts
组件 - 在
app.module.ts
中引用并添加到declarations
声明中 - 在
app.component.html
中使用组件<app-hello></app-hello>
命令创建
- 安装
Angular 5 Snippets
,输入命令ng-component
自动生成组件结构 - 使用ng命令自动创建模块:
ng generate component component-name
- 组件会自动加入到
declarations
声明中