npm install -g @angular/cli
創(chuàng)建新項目
ng new angular-demo
啟動項目
ng serve
還可以加上參數(shù):
ng serve --open
使用--open(或-o)參數(shù)可以自動打開瀏覽器并訪問http://localhost:4200/。ng g component component-name
g
是generate
的縮寫
還可以創(chuàng)建其他文件:
// 創(chuàng)建類
ng g class class-name
// 創(chuàng)建指令
ng g directive directive-name
// 創(chuàng)建模塊
ng g module module-name
// 創(chuàng)建管道
ng g pipe pipe-name
// 創(chuàng)建服務
ng g service service-name
啟動測試
ng test
編譯項目
ng build
更多命令:Angular CLI
更多建議: