从角网址中删除#时页面重新加载不起作用

时间:2014-10-17 20:55:03

标签: angularjs

我正在尝试使用

从我的angularjs网址中删除#
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
我的<base href="/">中的

index.html我已将部分内容中的href从#/abc更改为/abc

它在浏览网站内的链接时工作正常,但是除了我的主页,在其他每个页面上,当我尝试重新加载页面或复制并粘贴链接(并点击回车)时,它给了我错误。我在网上做了很多搜索没有运气。我希望这里有人已经完成了这个并且可以帮助我。 感谢

1 个答案:

答案 0 :(得分:0)

因此,如果您使用玉,您应该执行以下操作:

app.get('/', index);
// while index is defined in routes.js and jade is defined as template engine

如果您正在使用带有普通html文件的angularjs模板引擎,请执行以下操作:

exports.index = function(req, res) {
     res.sendfile(__dirname + "/public/index.html");
};

app.get('/', index);