搭建AngualarJS開發環境
1.選擇Web瀏覽器
Chrome和Firefox瀏覽器
2.選擇代碼編輯器
Subline Text和Visual Studio Code
3.安裝Web服務器
3.1Apache HTTP Server
官方網站: https://httpd.apache.org/ 說明Httpd和Tomcat都是出自Apache基金會的,但是是2個不同的東西。
因為從新版本開始,Apache官方網站不提供.exe的安裝程序給到windows用戶,所以需要到 http://httpd.apache.org/docs/current/platform/windows.html#down 找到下載地址,下載完成之后也不知之前的exe安裝文件,不過在bin文件夾中可以找到httpd.exe。如下圖所示:

3.2安裝Node.js加載connect模塊啟動一個簡單的web服務器
connect模塊安裝路徑:C:\Users\Administrator\AppData\Roaming\npm\node_modules\connect
運行node server.js出現如下錯誤:

問題:原因是書上作者的connect模塊的版本比較低。同時要引入serve-static模塊,我沒有升
級connect模塊,只是直接安裝npm install serve-static。
參考地址: http://stackoverflow.com/questions/24346161/nodejs-connect-cannot-find-static
server.js代碼修改如下:
var connect=require('connect'); var serverStatic=require('serve-static'); var app=connect(); app.use(serverStatic("../angularjs")); app.listen(5000);
4 運行結果
我在angularjs文件夾中新建了一個index.html,然后寫了一個hello world。運行成功結果如圖:

github地址: https://github.com/liminjun/liminjun.github.io/issues/12
segemtfault地址: https://segmentfault.com/a/1190000004334860