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)子組件