我使用角度ui路由,工作正常-但在不支持html5mode的浏览器中,它必须回到hashbang,链接不起作用。
www.test.com/something < works
www.test.com/#/something <不工作。(重定向到test.com)
不太确定如何使散列链接工作?
我绝望的尝试:
if (window.history && window.history.pushState) {
// HTML5 history API is available.
$locationProvider.html5Mode({
enabled: true,
});
} else {
// hashbang mode.
window.location.hash = '/';
$locationProvider.html5Mode({
enabled: true,
});
}
$urlRouterProvider.otherwise("/");
$stateProvider
.state('statistics', {
url: "/statistics/:id",
templateUrl: '../path/statistics.html',
controller: 'ResultCtrl'
}
);发布于 2016-04-28 14:28:58
你只需要这样做:
$locationProvider.html5Mode({
enabled: true,
}).hashPrefix("#");发布于 2016-04-28 14:23:53
您启用了html5mode。这种模式基本上意味着站点不使用hashbang urls进行路由。我不认为你能同时支持。
删除以下代码:
$locationProvider.html5Mode({
enabled: true,
});更新
https://docs.angularjs.org/guide/$location#html5 5-模式
根据不需要测试推送状态支持的文档,如果不支持它,它会自动返回到hashbang。
https://stackoverflow.com/questions/36917384
复制相似问题