$locationShim
Location service that provides a drop-in replacement for the $location service provided in AngularJS.
class $locationShim {
constructor($injector: any, location: Location, platformLocation: PlatformLocation, urlCodec: UrlCodec, locationStrategy: LocationStrategy)
onChange(fn: (url: string, state: unknown, oldUrl: string, oldState: unknown) => void, err: (e: Error) => void = (e: Error) => { })
$$parse(url: string)
$$parseLinkUrl(url: string, relHref?: string): boolean
absUrl(): string
url(url?: string): string | this
url(): string
url(url: string): this
protocol(): string
host(): string
port(): number | null
path(path?: string | number): string | this
path(): string
path(path: string | number): this
search(search?: string | number | { [key: string]: unknown; }, paramValue?: string | number | boolean | string[]): {...}
search(): {...}
search(search: string | number | { [key: string]: unknown; }): this
search(search: string | number | { [key: string]: unknown; }, paramValue: string | number | boolean | string[]): this
hash(hash?: string | number): string | this
hash(): string
hash(hash: string | number): this
replace(): this
state(state?: unknown): unknown | this
state(): unknown
state(state: unknown): this
}
See also
Constructor
Parameters
|
Methods
$$parse() |
---|
Parses the provided URL, and sets the current URL to the parsed result. |
$$parseLinkUrl() |
---|
Parses the provided URL and its relative URL. |
absUrl() |
---|
Retrieves the full URL representation with all segments encoded according to rules specified in RFC 3986. |
ParametersThere are no parameters. Returns
|
|
url() |
---|
Retrieves the current URL, or sets a new URL. When setting a URL, changes the path, search, and hash, and returns a reference to its own instance.
ParametersThere are no parameters. Returns
|
|
protocol() |
---|
Retrieves the protocol of the current URL. |
ParametersThere are no parameters. Returns
|
|
host() |
---|
Retrieves the protocol of the current URL. |
ParametersThere are no parameters. Returns
|
In contrast to the non-AngularJS version
|
port() |
---|
Retrieves the port of the current URL. |
ParametersThere are no parameters. Returns
|
|
path() |
---|
Retrieves the path of the current URL, or changes the path and returns a reference to its own instance.
ParametersThere are no parameters. Returns
|
Paths should always begin with forward slash (/). This method adds the forward slash if it is missing.
|
search() | |||
---|---|---|---|
|
search
|
string | number | { [key: string]: unknown; } |
Returns
this
Overload #3
// given URL http://example.com/#/some/path?foo=bar&baz=xoxo
let searchObject = $location.search();
// => {foo: 'bar', baz: 'xoxo'}
// set foo to 'yipee'
$location.search('foo', 'yipee');
// $location.search() => {foo: 'yipee', baz: 'xoxo'}
hash() |
---|
Retrieves the current hash fragment, or changes the hash fragment and returns a reference to its own instance.
ParametersThere are no parameters. Returns
|
|
replace() |
---|
Changes to |
ParametersThere are no parameters. Returns
|
state() |
---|
Retrieves the history state object when called without any parameter.
ParametersThere are no parameters. Returns
|
Change the history state object when called with one parameter and return This method is supported only in HTML5 mode and only in browsers supporting
the HTML5 History API methods such as |