My application have a url like this: "http://host:port/mySystem?x.system
"
我的应用程序有一个这样的URL:“http:// host:port / mySystem?x.system”
The x.system had to be added because a legacy application need this stuff on all url's, and my application depends on this legacy application.
必须添加x.system,因为遗留应用程序需要在所有url上使用这些东西,而我的应用程序依赖于这个遗留应用程序。
My problem is that i need the pure url of the system like this : "http://host:port/mySystem
", but when i use $location.absUrl() it returns : "http://host:port/mySystem?x.system
"
我的问题是我需要系统的纯url:“http:// host:port / mySystem”,但是当我使用$ location.absUrl()时它返回:“http:// host:port / mySystem ?x.system”
There's a way to get the url with $location (or another service on angular), without the parameters ?
有一种方法可以获得$ location(或角度上的其他服务)的URL,没有参数?
1 个解决方案
#1
2
You can use $location
to pull out whatever you need to build a URL. Here is a Plunker from the official docs that shows all the different parts. You probably want something like this:
您可以使用$ location来提取构建URL所需的任何内容。这是来自官方文档的Plunker,显示了所有不同的部分。你可能想要这样的东西:
function buildBaseUrl() {
return $location.protocol() + '://' + $location.host() + ':' + $location.port() + $location.path()
}
#1
2
You can use $location
to pull out whatever you need to build a URL. Here is a Plunker from the official docs that shows all the different parts. You probably want something like this:
您可以使用$ location来提取构建URL所需的任何内容。这是来自官方文档的Plunker,显示了所有不同的部分。你可能想要这样的东西:
function buildBaseUrl() {
return $location.protocol() + '://' + $location.host() + ':' + $location.port() + $location.path()
}