1

My application have a url like this: "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.

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"

There's a way to get the url with $location (or another service on angular), without the parameters ?

4
  • 1
    try window.location instead Commented Oct 29, 2014 at 13:52
  • 1
    location.host + location.port() + location.path, something like this Commented Oct 29, 2014 at 13:57
  • 2
    @BiAiB, using Angular, this is a bad habit to use window.location Commented Oct 29, 2014 at 14:01
  • 2
    window.location is provided by Angular as $location. Commented Oct 29, 2014 at 20:52

1 Answer 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:

function buildBaseUrl() {
  return $location.protocol() + '://' + $location.host() + ':' + $location.port() + $location.path()
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.