application base URL
application base URL stripped of any filename
URL path prefix
An absolute URL is the full URL, including protocol (http/https ), the optional subdomain (e.g. www ), domain (example.com), and path (which includes the directory and slug).
The hash string, minus the hash symbol
If html5 mode is enabled
The pathname, beginning with "/"
The port, without ":"
Has any change been replacing?
Helper property for scope watch changes
Return full URL representation with all segments encoded according to rules specified in RFC 3986.
full URL
This method is getter / setter.
Returns the hash fragment when called without any parameters.
Changes the hash fragment when called with a parameter and returns $location
.
// given URL http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue
let hash = $location.hash();
// => "hashValue"
New hash fragment
hash
This method is getter / setter.
Return path of current URL when called without any parameter.
Change path when called with parameter and return $location
.
Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing.
// given URL http://example.com/#/some/path?foo=bar&baz=xoxo
let path = $location.path();
// => "/some/path"
New path
path if called with no parameters, or $location
if called with a parameter
Return protocol of current URL.
protocol of current URL
If called, all changes to $location during the current $digest
will replace the current history
record, instead of adding a new one.
Returns or sets the search part (as object) of current URL when called without any parameter
New search params - string or hash object.
If search is a string or number, then paramValue will override only a single search property.
Rest
...args: anySearch object or Location object
This method is getter / setter.
Return the history state object when called without any parameter.
Change the history state object when called with one parameter and return $location
.
The state object is later passed to pushState
or replaceState
.
See https://developer.mozilla.org/en-US/docs/Web/API/History/pushState#state|History.state
NOTE: This method is supported only in HTML5 mode and only in browsers supporting
the HTML5 History API (i.e. methods pushState
and replaceState
). If you need to support
older browsers (like IE9 or Android < 4.0), don't use this method.
State object for pushState or replaceState
Rest
...args: anystate
This method is getter / setter.
Return URL (e.g. /path?a=b#hash
) when called without any parameter.
Change path, search and hash, when called with parameter and return $location
.
New URL without base prefix (e.g. /path?a=b#hash
)
url
This object is exposed as $location service when HTML5 mode is enabled and supported