angular6學習(五):建立組鍵
阿新 • • 發佈:2018-12-12
兩種建立方式:手動建立和命令建立
手動建立:
一:基礎知識:
程式碼說明:
二:程式碼實現:
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組鍵即可
--------------------- 本文來自 七刀 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/u011321546/article/details/80739636?utm_source=copy