2014-03-26 136 views
0

我只是跟着從http://scotch.io/bar-talk/setting-up-a-mean-stack-single-page-application如何使用Angular.js處理頁面刷新?

本教程介紹了控制器和服務angular.js一個單頁的應用程序的設置..

當我直接瀏覽/網頁,或點擊錨鏈接, /網頁的路線,然後按瀏覽器的「刷新」,頁面顯示:

Error: ENOENT, stat './public/views/index.html' 

閱讀一些回答類似的問題後,我改變了:

app.get('*', function(req, res) { 
    res.sendfile('./public/views/index.html'); 
}); 

到:

res.sendfile(__dirname + '/public/views/index.html'); 

..though現在的結果是Error: ENOENT, stat '/app/app/public/views/index.html'

+0

什麼是index.html的正確完整路徑? –

+0

/Users/username/appMainFolder/public/index.html on our local comp .. app/public/index.html on heroku? – StackThis

回答

1

好,首先,你的文件是./public/index.html,和你在./public/views/index.html搜索,嘗試:

res.sendfile('./public/index.html'); 

如果沒有工作,試試這個:

app.get('*', function(req, res) { 
    res.sendfile('index.html', { root: './public' }); 
}); 
+0

很好找。謝謝 – StackThis