加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular6学习(五):创建组键

发布时间:2020-12-17 08:10:42 所属栏目:安全 来源:网络整理
导读:两种创建方式:手动创建和命令创建 手动创建: 一:基础知识: 代码说明: 二:代码实现: 1.在app目录中新建组键目录和文件 2.ts文件中添加修饰器和引入模板 import {Component} from '@angular/core';@Component({ selector: 'app-server',templateUrl: '.

两种创建方式:手动创建和命令创建

手动创建:

一:基础知识:


代码说明:


二:代码实现:

1.在app目录中新建组键目录和文件


2.ts文件中添加修饰器和引入模板


import {Component} from '@angular/core';

@Component({
  selector: 'app-server',templateUrl: './server.component.html'
  })
export class ServerComponent {

}

3.html文件中添加内容


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>这是一个server主键</p>
</body>
</html>

4.在文件app.modul.ts中添加server组键


5.在文件app.componert.html中引用server组键



显示如下:



命令创建:

一:Alt+F12打开命令模式,输入ng generate component servers

或者缩写ng g c servers

指定创建组键servers

自动创建组建目录和文件,并自动在modul中添加



二:在文件app.componert.html中引用servers组键即可

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读