UrlRouter | UI-Router
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UrlRouter

Hierarchy

  • UrlRouter

Index

Methods

  • 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
    
    $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
      person: "bob"
    });
    // $bob == "/about/bob";
    

    Parameters

    • urlMatcher: UrlMatcher
      :

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

    • params: any
      :

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

    • options: object
      :

      Options object. The options are:

      • absolute: boolean

    Returns string

    :

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


  • listen(): Function
  • Starts listening for URL changes

  • Starts 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.

    Returns Function


  • Internal API.

    Pushes a new location to the browser history.

    Parameters

    Returns void


  • sync(): void
  • Checks the current URL for a matching rule

  • Checks the current URL for a matching rule

    Triggers an update; the same update that happens when the address bar url changes, aka $locationChangeSuccess. This method is useful when you need to use preventDefault() on the $locationChangeSuccess event, perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed with the transition by calling $urlRouter.sync().

    example
    
    angular.module('app', ['ui.router'])
      .run(function($rootScope, $urlRouter) {
        $rootScope.$on('$locationChangeSuccess', function(evt) {
          // Halt state change from even starting
          evt.preventDefault();
          // Perform custom logic
          var meetsRequirement = ...
          // Continue with the update and state transition if logic allows
          if (meetsRequirement) $urlRouter.sync();
        });
    });
    

    Returns void


  • update(read?: boolean): void
  • Internal API.

Generated using TypeDoc