【发布时间】:2014-06-23 17:00:51
【问题描述】:
如果我的网址是http://www.something.com/foo/bar/index.html?color=yellow&animal=rat,看起来好像:
-
$location.path()将返回foo/bar/index.html -
$location.absUrl()将返回http://www.something.com/foo/bar/index.html?color=yellow&animal=rat -
$location.url()将返回foo/bar/index.html?color=yellow&animal=rat
是否有任何函数会返回http://www.something.com/foo/bar/index.html?
或者我是否必须自己使用协议、主机、端口等函数来构建它(或者我自己剥离查询参数)?
【问题讨论】:
-
当我这样做时,我必须自己构建它。如果没有必要,我会很高兴。
-
$location.absUrl() 不是返回你想要的,或者你为什么不只是剥离?最后?
-
$location.absUrl() 末尾有查询参数 ("?color=yellow&animal=rat")。很容易剥离,但我只是想知道是否有内置功能,因为它们似乎具有几乎所有其他功能。
-
您反对使用$window服务吗? $window.location.origin + $window.location.pathname 应该可以得到你想要的。
-
看来只能自己构建了。
标签: angularjs url location-provider