为什么AngularJS在我的路由中复制查询字符串?

djs*_*ith 5 javascript web angularjs angularjs-routing

我在我的AngularJS应用程序中使用基于哈希的导航/.

如果用户导航到我的应用程序,请执行以下操作:

http://example.com/?foo

页面加载后的一刻,某些东西(可能是Angular)导致地址栏看起来与我预期的不同.

我看到了什么:

http://example.com/?foo#/?foo

我期望看到的内容:

http://example.com/?foo#/

为什么会发生这种情况,我可以将其关闭吗?

Ran*_*llB 3

我敢打赌你需要处于“html5 模式”才能没有哈希片段......尽管我不确定。

http://docs.angularjs.org/guide/dev_guide.services .$location

$locationProvider.html5Mode(true).hashPrefix('!');
Run Code Online (Sandbox Code Playgroud)

在您的应用程序配置中,您可以弄乱该配置参数,它可能会摆脱它。