angularjs$位置服务和地址栏随+;更改;,路线图中的空间

angularjs$位置服务和地址栏随+;更改;,路线图中的空间,angularjs,urlencode,angularjs-routing,Angularjs,Urlencode,Angularjs Routing,我使用的是angularjs 1.2.10、ngRoute和默认的html5模式false。 使用以下url示例: http://example.com/#/route?message=test+message 在Chrome、firefox和IE9中,我注意到以下参数转换: ?message=test+message - > ?messagetest%2Bmessage 我正在将nextLocation和currentRoute、nextRoute分别记录在$locationCh

我使用的是angularjs 1.2.10、ngRoute和默认的html5模式false。 使用以下url示例:

http://example.com/#/route?message=test+message
在Chrome、firefox和IE9中,我注意到以下参数转换:

?message=test+message - > ?messagetest%2Bmessage  
我正在将nextLocation和currentRoute、nextRoute分别记录在$locationChangeStart/$locationChangeSuccess和$routeChangeStart/$routeChangeSuccess事件处理程序中,并看到以下输出:

locationChangeStart: http://example.com/#/route?message=test+message
locationChangeSuccess: http://example.com/#/route?message=test%2Bmessage
routeChangeStart: currentRoute: /route, nextRoute: /route
routeChangeSuccess: currentRoute: /route, nextRoute: /route
...
locationChangeStart: http://example.com/#/route?message=test%2Bmessage
locationChangeSuccess: http://example.com/#/route?message=test%2Bmessage
routeChangeStart: currentRoute: /route, nextRoute: /route
routeChangeSuccess: currentRoute: /route, nextRoute: /route
路由及其关联的控制器被实例化两次,这是不可取的。有没有办法防止这种双重实例化或将“+”重写为%2B

当参数值具有空格时,也会发生类似的行为。 在Chrome、IE9中,发生以下转换:

?message=test message - > ?message=test%20message
然而,这种重写(以及随后的双路由加载)并没有在firefox中发生,这让我相信这是一种特定于浏览器的行为


我无法直接控制参数是如何形成的,我们站点中的一个iframe正在重定向到“顶部”位置,同时添加参数。

我也面临类似的问题。希望我给出的这个解决方案能帮助你@Sai谢谢你的链接。我的情况似乎有点不同,因为iframe重定向到window.top是位置更改的触发器。我不确定是否可以截获此位置更改,并相应地在angular$摘要之前“修复”特殊字符。我尝试在事件$locationChangeStart和$routeChangeStart中执行此操作,但没有成功。您对参数没有控制权是什么意思?iframe无法访问父URL@Sai我相信iframe中的javascript代码运行的方式类似于window.top.location.href=“parent\u url\u redirect”参见