一、创建组件
1.创建一个 news组件
ng g component [组件目录/组件名称]
ng g component components/news
2.在VS Code中查看项目结构
3.如果通过命令行创建组件,将自动在 app.module.ts 中引入
二、使用组件
1.在 app.component.html 中添加 news 组件
<!--The content below is only a placeholder and can be replaced.-->
<app-news></app-news>
2.在 news.component.html 中添加内容
<h1>新闻组件</h1>
3.运行项目
ng serve --open