UrlSyncApi | @uirouter/angular
Options
Menu

Interface UrlSyncApi

Hierarchy

  • UrlSyncApi

Implemented by

Index

Methods

  • deferIntercept(defer?: boolean): any
  • 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
      :

      Indicates whether to defer location change interception. Passing no parameter is equivalent to true.

    Returns any


  • 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


  • 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


Generated using TypeDoc