When i try to add a hash in the url like :
当我尝试在网址中添加哈希时:
<a href="#whatever">whatever</a>
or
要么
window.location.hash = 'whatever';
it appends a '/' before the hash world
它在哈希世界之前附加一个'/'
=> www.mysite.com/#whatever
but it should be
但它应该是
=> www.mysite.com#whatever
I know this is caused by angular, but i can find a way to prevent it.
Is there a way to prevent this behaviour ?
我知道这是由角度引起的,但我可以找到一种方法来防止它。有没有办法防止这种行为?
Thanks
谢谢
2 个解决方案
#1
8
Turn on html5 mode:
打开html5模式:
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
})
See more detail here.
在这里查看更多细节。
#2
2
For those new to AngularJS world, configuration should be defined when declaring the module. E.g.:
对于AngularJS世界的新用户,应在声明模块时定义配置。例如。:
var someModule = angular.module("someModule", [/* dependent modules come here */],
function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true
});
});
#1
8
Turn on html5 mode:
打开html5模式:
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
})
See more detail here.
在这里查看更多细节。
#2
2
For those new to AngularJS world, configuration should be defined when declaring the module. E.g.:
对于AngularJS世界的新用户,应在声明模块时定义配置。例如。:
var someModule = angular.module("someModule", [/* dependent modules come here */],
function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true
});
});