Updates URL and responds to URL changes

### Deprecation warning:

This class is now considered to be an internal API Use the UrlService instead. For configuring URL rules, use the UrlRulesApi which can be found as UrlService.rules.

This class updates the URL when the state changes. It also responds to changes in the URL.

### Hierarchy

- UrlRouter

### Implements

- UrlRulesApi
- UrlSyncApi
- Disposable

## Index

### Properties

- urlRuleFactory

### Methods

- deferIntercept
- dispose
- ensureSorted
- href
- initial
- listen
- match
- otherwise
- push
- removeRule
- rule
- rules
- sort
- stableSort
- sync
- update
- when

## Properties

urlRuleFactory: UrlRuleFactory

used to create UrlRule objects for common cases

used to create UrlRule objects for common cases

- Defined in url/urlRouter.ts:90

## 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/urlRouter.ts:343

- dispose(): void

- #### Returns void

  - Defined in url/urlRouter.ts:110

- ensureSorted(): void

- #### Returns void

  - Defined in url/urlRouter.ts:122

- href(urlMatcher: UrlMatcher, params?: any, options?: object): string

- Builds and returns a URL with interpolated parameters

- Builds and returns a URL with interpolated parameters

  #### Example:

      matcher = $umf.compile("/about/:person");
      params = { person: "bob" };
      $bob = $urlRouter.href(matcher, params);
      // $bob == "/about/bob";

  #### Parameters

  - ##### urlMatcher UrlMatcher

    :

    The UrlMatcher object which is used as the template of the URL to generate.

  - ##### params: Optional any

    :

    An object of parameter values to fill the matcher's required parameters.

  - ##### options: Optional object

    :

    Options object. The options are:

    - `absolute` - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".

    - ##### absolute: boolean

  #### Returns string

  :

  Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`

  - Defined in url/urlRouter.ts:257

- initial(handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef): void

- inheritdoc

  #### Parameters

  - ##### handler string | UrlRuleHandlerFn | TargetState | TargetStateDef

  #### Returns void

  - Defined in url/urlRouter.ts:325

- 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/urlRouter.ts:199

- match(url: UrlParts): MatchResult

- Given a URL, check all rules and return the best MatchResult

- Given a URL, check all rules and return the best MatchResult

  #### Parameters

  - ##### url UrlParts

    :

  #### Returns MatchResult

  :

  - Defined in url/urlRouter.ts:144

- otherwise(handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef): void

- Defines the state, url, or behavior to use when no other rule matches the URL.

- Defines the state, url, or behavior to use when no other rule matches the URL.

  This rule is matched when no other rule matches. It is generally used to handle unknown URLs (similar to "404" behavior, but on the client side).

  - If `handler` a string, it is treated as a url redirect

  #### Example:

  When no other url rule matches, redirect to `/index`

      .otherwise('/index');

  - If `handler` is an object with a `state` property, the state is activated.

  #### Example:

  When no other url rule matches, redirect to `home` and provide a `dashboard` parameter value.

      .otherwise({ state: 'home', params: { dashboard: 'default' } });

  - If `handler` is a function, the function receives the current url (UrlParts) and the UIRouter object. The function can perform actions, and/or return a value.

  #### Example:

  When no other url rule matches, manually trigger a transition to the `home` state

      .otherwise((matchValue, urlParts, router) => {
        router.stateService.go('home');
      });

  #### Example:

  When no other url rule matches, go to `home` state

      .otherwise((matchValue, urlParts, router) => {
        return { state: 'home' };
      });

  #### Parameters

  - ##### handler string | UrlRuleHandlerFn | TargetState | TargetStateDef

  #### Returns void

  Implementation of UrlRulesApi.otherwise

  - Defined in url/urlRouter.ts:317

- push(urlMatcher: UrlMatcher, params?: RawParams, options?: object): void

- Internal API.

- Internal API.

  Pushes a new location to the browser history.

  #### Parameters

  - ##### urlMatcher UrlMatcher

    :

  - ##### params: Optional RawParams

    :

  - ##### options: Optional object

    :

    - ##### Optional replace?: string | true | false

  #### Returns void

  - Defined in url/urlRouter.ts:233

- removeRule(rule: any): void

- inheritdoc

  #### Parameters

  - ##### rule any

  #### Returns void

  - Defined in url/urlRouter.ts:306

- rule(rule: UrlRule): Function

- Manually adds a URL Rule.

- Manually adds a URL Rule.

  Usually, a url rule is added using StateDeclaration.url or when. This api can be used directly for more control (to register a BaseUrlRule, for example). Rules can be created using UrlRouter.urlRuleFactory, or create manually as simple objects.

  A rule should have a `match` function which returns truthy if the rule matched. It should also have a `handler` function which is invoked if the rule is the best match.

  #### Parameters

  - ##### rule UrlRule

  #### Returns Function

  :

  a function that deregisters the rule

  Implementation of UrlRulesApi.rule

  - Defined in url/urlRouter.ts:294

- rules(): UrlRule[]

- Gets all registered rules

- Gets all registered rules

  #### Returns UrlRule[]

  :

  an array of all the registered rules

  Implementation of UrlRulesApi.rules

  - Defined in url/urlRouter.ts:311

- sort(compareFn?: function): void

- inheritdoc

  #### Parameters

  - ##### compareFn: Optional function

    - - (a: UrlRule, b: UrlRule): number

      - #### Parameters

        - ##### a UrlRule

        - ##### b UrlRule

        #### Returns number

  #### Returns void

  - Defined in url/urlRouter.ts:117

- stableSort(arr: any, compareFn: any): any

- #### Parameters

  - ##### arr any

  - ##### compareFn any

  #### Returns any

  - Defined in url/urlRouter.ts:126

- 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/urlRouter.ts:176

- update(read?: boolean): void

- Internal API.

- Internal API.

  #### Parameters

  - ##### read: Optional boolean

  #### Returns void

  - Defined in url/urlRouter.ts:212

- when(matcher: string | RegExp | UrlMatcher, handler: string | UrlRuleHandlerFn, options?: object): UrlRule

- inheritdoc

  #### Parameters

  - ##### matcher string | RegExp | UrlMatcher

  - ##### handler string | UrlRuleHandlerFn

  - ##### options: Optional object

    - ##### priority: number

  #### Returns UrlRule

  - Defined in url/urlRouter.ts:335

Generated using TypeDoc