1.创建header组件

ng g component components/header

header.component.ts

import { Component, OnInit } from '@angular/core'; /*引入 angular 核心*/

@Component({
selector: 'app-header', /*使用这个组件的名称*/
templateUrl: './header.component.html', /*html 模板*/
styleUrls: ['./header.component.scss'] /*css 样式*/
})
export class HeaderComponent implements OnInit { /*实现接口*/ constructor() { }/*构造函数*/ ngOnInit() {/*初始化加载的生命周期函数*/
} }

2.在使用的地方使用组件

比如在跟组件下使用

<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center"> <h1>
Welcome to {{ title }}
</h1>
</div>
<app-header></app-header>
<router-outlet></router-outlet>

最新文章

  1. android微信分享不出去?四步搞定!
  2. 从零开始编写自己的C#框架(3)——开发规范
  3. 【原】PHP初体验
  4. Nutch源码阅读进程3---fetch
  5. 【C语言】二维指针做形参
  6. Spring —— 三种配置数据源的方式:spring内置、c3p0、dbcp
  7. Hadoop 一二事(1) - 简单介绍与杂谈
  8. android 项目学习随笔八(xUtils的BitmapUtils模块)
  9. Centos yum 安装mysql报错 No package mysql-server available.
  10. Python 通用爬虫 和讯博客 scrapy
  11. JAVA中的配置文件XML
  12. HashMap的源码分析
  13. 8.6 正睿暑期集训营 Day3
  14. ubuntu 18.04下安装Java
  15. Windows Service 之 Bug 记录
  16. Retrofit2完全教程
  17. shell中的环境变量:local,global,export
  18. Python学习-28.Python中的列表切片
  19. Qt信号槽的一些事
  20. 基数排序算法-python实现

热门文章

  1. kali linux tools
  2. 理解serverless无服务
  3. SpringBoot配置HTTPS,并实现HTTP访问自动转HTTPS访问
  4. Codeforces Round #511 (Div. 2) C. Enlarge GCD (质因数)
  5. Android加载大图到内存如何避免内存溢出?
  6. [GraphQL] Query Lists of Multiple Types using a Union in GraphQL
  7. GridView修改含有DropDownList控件列的宽度
  8. 使用webuploader实现大文件传输
  9. 洛谷P1006 传纸条(多维DP)
  10. tesonflow实现word2Vec