命令列表
名稱作用
ng init在當(dāng)前目錄下創(chuàng)建應(yīng)用
ng new創(chuàng)建新的目錄并在新目錄下運(yùn)行ng init命令
ng serve啟動(dòng)
ng doc在瀏覽器中打開(kāi)Angular文檔并搜索當(dāng)前關(guān)鍵字
ng e2e使用 protractor 在當(dāng)前應(yīng)用中運(yùn)行e2e測(cè)試
ng format使用 clang-format 格式化當(dāng)前項(xiàng)目代碼
ng generate在項(xiàng)目中構(gòu)建新代碼
ng gng generate的簡(jiǎn)寫(xiě)
ng build構(gòu)建項(xiàng)目
ng github-pages:deploy [options]將項(xiàng)目部署到GitHub Pages
ng version輸出cli版本, node 版本和操作系統(tǒng)信息
ng set設(shè)置環(huán)境
任何指令后面都可以加--help以查看幫助
ng new
參數(shù)名類型默認(rèn)值作用
--dry-runbooleanfalse只輸出要?jiǎng)?chuàng)建的文件和執(zhí)行的操作锻霎,實(shí)際上并沒(méi)有創(chuàng)建項(xiàng)目
--verbosebooleanfalse輸出詳細(xì)信息
--link-clibooleanfalse自動(dòng)連接到angular-cli包
--skip-installbooleanfalse在項(xiàng)目第一次創(chuàng)建時(shí)不執(zhí)行npm install
--skip-bowerbooleantrue不安裝bower
--skip-gitbooleanfalse不執(zhí)行Git repository初始化工作
--directorystring目錄名默認(rèn)與項(xiàng)目名稱一樣
--source-dirstring'src'源文件目錄名
--stylestring'css'使用 ('css', 'less' 還是 'scss')編寫(xiě)css
--prefixstring'app'生成新組件的前綴
--mobilebooleanfalse生成 Progressive Web App (PWA)項(xiàng)目
--routingbooleanfalse添加帶路由的模塊(module)并import到main app module中
--inline-stylebooleanfalse生成新應(yīng)用的時(shí)候使用inline styles(內(nèi)聯(lián),不生成單獨(dú)的css文件)方式
--inline-templatebooleanfalse生成新應(yīng)用的時(shí)候使用 inline templates(內(nèi)聯(lián)注服,不生成單獨(dú)的html文件)方式
--ng4無(wú)無(wú)使用Angular4的依賴創(chuàng)建空項(xiàng)目惋耙,現(xiàn)在默認(rèn)已經(jīng)是4的版本了
ng serve
參數(shù)名類型默認(rèn)值作用
--hoststring12.0.0.1自定義配置 IP
--disable-host-check----跟在--host后面,允許使用localhost以外的host打開(kāi)項(xiàng)目
--portnumber4200自定義端口號(hào)
--live-reload-portnumber4200時(shí)時(shí)重載端口號(hào)
--hmr----熱替換
ng generate支持的類型
名稱示例
Componentng g component my-new-component
Directiveng g directive my-new-directive
Pipeng g pipe my-new-pipe
Serviceng g service my-new-service
Classng g class my-new-class
Interfaceng g interface my-new-interface
Enumng g enum my-new-enum
Moduleng g module my-module
Routeng g route my-route 當(dāng)前已禁用
命令參數(shù)
ng generate class
參數(shù)名類型默認(rèn)值作用
--specbooleanfalse生成對(duì)應(yīng)的單元測(cè)試文件
ng generate component
參數(shù)名類型默認(rèn)值作用
--flatbooleanfalse在src/app中生成component文件,而不是在當(dāng)前目錄下
--inline-templatebooleanfalse使用inline template浇揩,而不是獨(dú)立的HTML文件
--inline-stylebooleanfalse使用inline styles仪壮,而不是獨(dú)立的CSS文件
--prefixbooleantrue使用在angular-cli.json指定的前綴來(lái)生成component selector(前綴表示selector的第一個(gè)單詞)
--specbooleantrue生成對(duì)應(yīng)的單元測(cè)試文件
ng generate directive
參數(shù)名類型默認(rèn)值作用
--flatbooleanfalse在src/app中生成component文件,而不是在當(dāng)前目錄下
--prefixbooleantrue默認(rèn)true, 使用在angular-cli.json指定的前綴來(lái)生成component selector(前綴表示selector的第一個(gè)單詞)
--specbooleantrue生成對(duì)應(yīng)的單元測(cè)試文件
ng generate module
參數(shù)名類型默認(rèn)值作用
--routingbooleanfalse新增一個(gè)與module對(duì)應(yīng)的路由模塊胳徽,并import到module中
--specbooleanfalse用于檢測(cè)模塊是否存在
ng generate service
參數(shù)名類型默認(rèn)值作用
--flatbooleantrue在src/app中生成component文件积锅,而不是在當(dāng)前目錄下
--specbooleantrue生成單元測(cè)試文件
ng build
參數(shù)名類型默認(rèn)值作用
--aotstring無(wú)預(yù)編譯
--base-hrefstring‘/’設(shè)置index.html文件中的base href參數(shù)
--environmentstringdev在哪個(gè)環(huán)境中使用,prod代表生成環(huán)境
--output-pathstringdist文件輸出目標(biāo)路徑
--targetstringdevelopmentdevelopment:默認(rèn)值爽彤,不壓縮混淆,production:壓縮混淆代碼
--watchbooleanfalse在哪個(gè)環(huán)境中使用
ng github-pages:deploy
參數(shù)名類型默認(rèn)值作用
--messagestring無(wú)構(gòu)建的時(shí)候提交的message缚陷,必須寫(xiě)在引號(hào)中
--targetstringdevelopment使用的環(huán)境
--user-pagebooleanfalse是否以u(píng)ser/org頁(yè)面部署到GitHub上
--skip-buildbooleanfalse跳過(guò)構(gòu)建直接部署
--gh-tokenstring無(wú)使用Github的token
--gh-usernamestring無(wú)使用Github用戶名
--base-hrefstring'/'在index.html文件中使用的base href值
ng set
參數(shù)名類型默認(rèn)值作用
--global--無(wú)是否設(shè)置全局
packageManagerstring無(wú)可設(shè)置為npm\cnpm\yarn
更多命令參數(shù),可參考官網(wǎng):https://github.com/angular/angular-cli/wiki
作者:偶爾裝沉默
鏈接:http://www.reibang.com/p/384cc631f0fa
來(lái)源:簡(jiǎn)書(shū)
著作權(quán)歸作者所有适篙。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處箫爷。