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

Class UrlRouter

Hierarchy

  • UrlRouter

Index

Constructors

Properties

listener: Function
location: string
urlRouterProvider: UrlRouterProvider

Methods

  • href(urlMatcher: UrlMatcher, params: any, options: any): string
  • ngdoc

    function

    name

    ui.router.router.$urlRouter#href

    methodof

    ui.router.router.$urlRouter

    description

    A URL generation method that returns the compiled URL for a given {@link ui.router.util.type:UrlMatcher UrlMatcher}, populated with the provided 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: any
      :

      Options object. The options are:

    Returns string

    :

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


  • listen(): Function
  • push(urlMatcher: any, params: any, options: any): void
  • sync(): void
  • ngdoc

    function

    name

    ui.router.router.$urlRouter#sync

    methodof

    ui.router.router.$urlRouter

    description

    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?: any): void

Generated using TypeDoc