去除AngularJS查询字符串 [英] Removing the querystring in AngularJS

查看:87
本文介绍了去除AngularJS查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

读取并处理来自URL的查询字符串值,例如后

After reading and processing a query-string value from the URL, for example

http://myurl.com/#/?foo=baa

我可以将URL更改为

I can change the URL to

http://myurl.com/#/?foo=

$location.search('myQueryStringParameter', '');

我如何才能彻底摆脱了查询字符串的(没有明确的重定向或服务器端操作等),这样只有

How do I get rid of the query-string altogether (without explicit redirects or server side action and so on) so that only

http://myurl.com/#/

保留在浏览器?它应该是相当简单的,但我找不到任何引用。

remains in the browser? It should be fairly simple, but I can't find any reference.

推荐答案

试试这个:

$location.url($location.path())

请参阅文档以获取更多信息。

See documentation for more information.

这篇关于去除AngularJS查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆