Class: Location service:ngeoLocation

ngeo.Location

new Location(location, history)

Provides a service for interacting with the URL in the browser address bar.

WARNING: because of a bug in Angular this service is not compatible with the $location service. This further means that service is not compatible with the $anchorScroll and $route services, and with the ng-include and ng-view directives (which are based on the $anchorScroll and $route services). See https://github.com/angular/angular.js/issues/1417.

This file also provides an ngeo.mockLocationProvider function that you can use to mock Angular's $location provider and make it possible to use both ngeoLocation and ng-include.

app.module.config(ngeo.mockLocationProvider);

The ngeo Location type.

See our live example: ../examples/permalink.html

Parameters:
Name Type Description
location Location

Location.

history History

History.

Methods

deleteFragmentParam(key)

Delete a param int the fragment of the location's URI.

Parameters:
Name Type Description
key string

Param key.

deleteParam(key)

Delete a param in the location's URI.

Parameters:
Name Type Description
key string

Param key.

getFragmentParam(key)

Get a param from the fragment of the location's URI.

Parameters:
Name Type Description
key string

Param key.

Returns:
string|undefined

Param value.

getFragmentParamAsInt(key)

Get a param from the fragment of the location's URI as integer. If the entry does not exist, or if the value can not be parsed as integer, undefined is returned.

Parameters:
Name Type Description
key string

Param key.

Returns:
number|undefined

Param value.

getFragmentParamKeys()

Get an array with all existing param's keys from the fragment of the location's URI.

Returns:
Array.

Param keys.

getFragmentParamKeysWithPrefix(prefix)

Get an array with all existing param's keys from the fragment of the location's URI that start with the given prefix.

Parameters:
Name Type Description
prefix string

Key prefix.

Returns:
Array.

Param keys.

getParam(key)

Get a param in the location's URI.

Parameters:
Name Type Description
key string

Param key.

Returns:
string|undefined

Param value.

getParamAsInt(key)

Get a param in the location's URI as integer. If the entry does not exist, or if the value can not be parsed as integer, undefined is returned.

Parameters:
Name Type Description
key string

Param key.

Returns:
number|undefined

Param value.

getParamKeys()

Get an array with all existing param's keys in the location's URI.

Returns:
Array.

Param keys.

getParamKeysWithPrefix(prefix)

Get an array with all existing param's keys in the location's URI that start with the given prefix.

Parameters:
Name Type Description
prefix string

Key prefix.

Returns:
Array.

Param keys.

getPath()

Get the location's current path.

Returns:
string|undefined

The path.

getUriString()

Get the location's URI as a string

Returns:
string

The URI.

hasFragmentParam(key)

Check if a param exists in the fragment of the location's URI.

Parameters:
Name Type Description
key string

Param key.

Returns:
boolean

True if the param exists.

hasParam(key)

Check if a param exists in the location's URI.

Parameters:
Name Type Description
key string

Param key.

Returns:
boolean

True if the param exists.

refresh()

Refresh the the location's URI.

setPath(path)

Set a new path for this location.

Parameters:
Name Type Description
path string

Path.

updateFragmentParams(params)

Set or create a param in the fragment of the location's URI.

Parameters:
Name Type Description
params !Object.

Parameters.

updateParams(params)

Set or create a param in the location's URI.

Parameters:
Name Type Description
params !Object.

Parameters.