API for URL management

### Hierarchy

- UrlService

### Implements

- LocationServices
- UrlSyncApi

## Index

### Properties

- config
- rules

### Methods

- deferIntercept
- dispose
- hash
- listen
- match
- onChange
- parts
- path
- search
- sync
- url

## Properties

config: UrlConfigApi

A nested API to configure the URL and retrieve URL information

A nested API to configure the URL and retrieve URL information

See: UrlConfigApi for details

- Defined in url/urlService.ts:44

rules: UrlRulesApi

A nested API for managing URL rules and rewrites

A nested API for managing URL rules and rewrites

See: UrlRulesApi for details

- Defined in url/urlService.ts:37

## Methods

- deferIntercept(defer?: boolean): void

- Disables monitoring of the URL.

- Disables monitoring of the URL.

  Call this method before UI-Router has bootstrapped. It will stop UI-Router from performing the initial url sync.

  This can be useful to perform some asynchronous initialization before the router starts. Once the initialization is complete, call listen to tell UI-Router to start watching and synchronizing the URL.

  #### Example:

      // Prevent $urlRouter from automatically intercepting URL changes when it starts;
      urlService.deferIntercept();

      $http.get('/states.json').then(function(resp) {
        resp.data.forEach(state => $stateRegistry.register(state));
        urlService.listen();
        urlService.sync();
      });

  #### Parameters

  - ##### defer: Optional boolean

  #### Returns void

  Implementation of UrlSyncApi.deferIntercept

  - Defined in url/urlService.ts:103

- dispose(): void

- #### Returns void

  - Defined in url/urlService.ts:96

- hash(): string

- Gets the hash part of the current url

- Gets the hash part of the current url

  If the current URL is `/some/path?query=value#anchor`, this returns `anchor`

  #### Returns string

  :

  the hash (anchor) portion of the url

  Implementation of LocationServices.hash

  - Defined in url/urlService.ts:80

- listen(enabled?: boolean): Function

- Starts or stops listening for URL changes

- Starts or stops listening for URL changes

  Call this sometime after calling deferIntercept to start monitoring the url. This causes UrlRouter to start listening for changes to the URL, if it wasn't already listening.

  If called with `false`, will stop listening. Call listen() again to start listening

  #### Example:

      urlService.deferIntercept();

      $http.get('/states.json').then(function(resp) {
        resp.data.forEach(state => $stateRegistry.register(state));
        // Start responding to URL changes
        urlService.listen();
        urlService.sync();
      });

  #### Parameters

  - ##### enabled: Optional boolean

  #### Returns Function

  Implementation of UrlSyncApi.listen

  - Defined in url/urlService.ts:101

- match(urlParts: UrlParts): MatchResult

- inheritdoc

  #### Parameters

  - ##### urlParts UrlParts

  #### Returns MatchResult

  - Defined in url/urlService.ts:105

- onChange(callback: Function): Function

- Registers a url change handler

- Registers a url change handler

  #### Example:

      let deregisterFn = locationServices.onChange((evt) => console.log("url change", evt));

  #### Parameters

  - ##### callback Function

  #### Returns Function

  :

  a function that de-registers the callback

  Implementation of LocationServices.onChange

  - Defined in url/urlService.ts:82

- parts(): UrlParts

- Returns the current URL parts

- Returns the current URL parts

  This method returns the current URL components as a UrlParts object.

  #### Returns UrlParts

  :

  the current url parts

  - Defined in url/urlService.ts:92

- path(): string

- Gets the path part of the current url

- Gets the path part of the current url

  If the current URL is `/some/path?query=value#anchor`, this returns `/some/path`

  #### Returns string

  :

  the path portion of the url

  Implementation of LocationServices.path

  - Defined in url/urlService.ts:76

- search(): object

- Gets the search part of the current url as an object

- Gets the search part of the current url as an object

  If the current URL is `/some/path?query=value#anchor`, this returns `{ query: 'value' }`

  #### Returns object

  :

  the search (querystring) portion of the url, as an object

  - ##### [key: string]: any

  Implementation of LocationServices.search

  - Defined in url/urlService.ts:78

- sync(evt?: any): void

- Checks the URL for a matching UrlRule

- Checks the URL for a matching UrlRule

  Checks the current URL for a matching url rule, then invokes that rule's handler. This method is called internally any time the URL has changed.

  This effectively activates the state which matches the current URL.

  #### Example:

      urlService.deferIntercept();

      $http.get('/states.json').then(function(resp) {
        resp.data.forEach(state => $stateRegistry.register(state));
        urlService.listen();
        // Find the matching URL and invoke the handler.
        urlService.sync();
      });

  #### Parameters

  - ##### evt: Optional any

  #### Returns void

  Implementation of UrlSyncApi.sync

  - Defined in url/urlService.ts:99

- url(): string

- Gets the current url string

- url(newurl: string, replace?: boolean, state?: any): void

- Updates the url, or gets the current url

- Gets the current url string

  The URL is normalized using the internal path/search/hash values.

  For example, the URL may be stored in the hash ([[HashLocationServices]]) or have a base HREF prepended ([[PushStateLocationServices]]).

  The raw URL in the browser might be:

      http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor

  or

      http://mysite.com/basepath/internal/path/123?param1=foo#anchor

  then this method returns:

      /internal/path/123?param1=foo#anchor

  #### Example:

      locationServices.url(); // "/some/path?query=value#anchor"

  #### Returns string

  :

  the current value of the url, as a string.

  Implementation of LocationServices.url

  - Defined in url/urlService.ts:71

- Updates the url, or gets the current url

  Updates the url, changing it to the value in `newurl`

  #### Example:

      locationServices.url("/some/path?query=value#anchor", true);

  #### Parameters

  - ##### newurl string

  - ##### replace: Optional boolean

  - ##### state: Optional any

  #### Returns void

  :

  the url (after potentially being processed)

  Implementation of LocationServices.url

  - Defined in url/urlService.ts:73

Generated using TypeDoc