angularcli 第一篇(新建、組件、模塊)


 

1、新建並啟動項目:

1、安裝:   npminstall -g @angular/cli
2、新建:   ng new mytest
3、進入項目:cd mytest
4、啟動:   ng serve
5、打開項目: localhost:4200
注:拿到項目之后首先要:cnpm install然后才運行:ng serve (安裝依賴:項目要跑起來首先要依賴一些包,cnpm install后會自動找到package.json匹配相應的包,進行下載,下載完裝在node_modules里)

 

2、新建組件:

ng g component header

注: 只需要記得在 app.component.html 中加入 <app-header></app-header> 就可以看到header.component.html中編輯的內容。訪問 http://localhost:4200/ 將會看到。

3、組件和模塊介紹:

(1)根模塊

(2)根組件

(3)子組件

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM