[英]How do I handle Page Refresh with Angular.js?
我只是按照http://scotch.io/bar-talk/setting-up-a-mean-stack-single-page-application的设置进行操作
本教程为单页应用程序介绍了带有angular.js的控制器和服务。
当我直接访问/ pageName或单击/ pageName路线的锚链接,然后按浏览器“刷新”时,页面显示:
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');
..尽管现在结果为Error: ENOENT, stat '/app/app/public/views/index.html'
好吧,首先,您的文件位于./public/index.html
,而您正在./public/views/index.html
进行搜索,请尝试:
res.sendfile('./public/index.html');
如果那不起作用,请尝试以下操作:
app.get('*', function(req, res) {
res.sendfile('index.html', { root: './public' });
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.