为什么 AngularJS 在我的路由中复制查询字符串? [英] Why is AngularJS duplicating the query string in my route?
问题描述
我在以 /
为根的 AngularJS 应用程序中使用基于哈希的导航.
I am using hash-based navigation in my AngularJS app rooted at /
.
如果用户像这样导航到我的应用程序:
If a user navigates to my app like this:
http://example.com/?foo
页面加载后片刻,某些东西(可能是 Angular)导致地址栏看起来与我预期的不同.
A moment after the page loads, something (possibly Angular) is causing the address bar to look different than I expected.
我看到了什么:
http://example.com/?foo#/?foo
我希望看到的:
http://example.com/?foo#/
为什么会发生这种情况,我可以关闭它吗?
Why is this happening, and can I turn it off?
推荐答案
我打赌你需要处于html5 模式"才能没有哈希片段......虽然我不确定.
I'd wager you need to be in 'html5 mode' to not have the hash fragment... though I'm uncertain.
http://docs.angularjs.org/guide/dev_guide.services.$位置
$locationProvider.html5Mode(true).hashPrefix('!');
在您的应用配置中,您可以弄乱该配置参数,它可能会摆脱它.
In your app configuration, you can mess with that config param and it'd probably get rid of it.
这篇关于为什么 AngularJS 在我的路由中复制查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!