LocationServices | @uirouter/angularjs
Options
Menu

Interface LocationServices

Hierarchy

Implemented by

Index

Methods

  • dispose(router?: UIRouter): any
  • Instructs the Disposable to clean up any resources

  • 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


  • 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
      :

      a function that will be called when the url is changing

    Returns Function

    :

    a function that de-registers the callback


  • 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


  • 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

  • url(): string
  • Gets the current url string

  • url(newurl: string, replace?: boolean, state?: any): string
  • 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.


  • 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
      :

      The new value for the URL. This url should reflect only the new internal path, search, and hash values. It should not include the protocol, site, port, or base path of an absolute HREF.

    • replace: Optional  boolean
      :

      When true, replaces the current history entry (instead of appending it) with this new url

    • state: Optional  any
      :

      The history's state object, i.e., pushState (if the LocationServices implementation supports it)

    Returns string

    :

    the url (after potentially being processed)


Generated using TypeDoc