injectables | angular-ui-router
Options
Menu

Module injectables

Angular 1 injectable services

This is a list of the objects which can be injected using angular's injector.

There are three different kind of injectable objects:

Provider objects

injectable into a .config() block during configtime

Service objects

injectable globally during runtime

Per-Transition objects

Different instances are injected based on the Transition

Index

Variables

$state: StateService

The State Service

The State Service

The StateService singleton as a Service Object (injectable during runtime).

This service used to manage and query information on registered states. It exposes state related APIs including:

  • Start a Transition
  • Imperatively lazy load states
  • Check if a state is currently active
  • Look up states by name
  • Build URLs for a state+parameters
  • Configure the global Transition error handler

This angular service exposes the StateService singleton.

$stateParams: StateParams

The current (or pending) State Parameters

The current (or pending) State Parameters

An injectable global Service Object which holds the state parameters for the latest SUCCESSFUL transition.

The values are not updated until after a Transition successfully completes.

Also: an injectable Per-Transition Object object which holds the pending state parameters for the pending Transition currently running.

Deprecation warning:

The value injected for $stateParams is different depending on where it is injected.

  • When injected into an angular service, the object injected is the global Service Object with the parameter values for the latest successful Transition.
  • When injected into transition hooks, resolves, or view controllers, the object is the Per-Transition Object with the parameter values for the running Transition.

Because of these confusing details, this service is deprecated.

Instead of using the global $stateParams service object,

inject $uiRouterGlobals and use UIRouterGlobals.params

MyService.$inject = ['$uiRouterGlobals'];
function MyService($uiRouterGlobals) {
  return {
    paramValues: function () {
      return $uiRouterGlobals.params;
    }
  }
}

Instead of using the per-transition $stateParams object,

inject the current Transition (as $transition$) and use Transition.params

MyController.$inject = ['$transition$'];
function MyController($transition$) {
  var username = $transition$.params().username;
  // .. do something with username
}

This object can be injected into other services.

Deprecated Example:

SomeService.$inject = ['$http', '$stateParams'];
function SomeService($http, $stateParams) {
  return {
    getUser: function() {
      return $http.get('/api/users/' + $stateParams.username);
    }
  }
};
angular.service('SomeService', SomeService);
deprecated
$stateProvider: StateProvider

The StateProvider

The StateProvider

An angular1-only StateProvider as a Provider Object (injectable during config time).

This angular service exposes the StateProvider singleton.

The StateProvider is primarily used to register states or add custom state decorators.

Note: This provider is a ng1 vestige.

It is a passthrough to $stateRegistry and $state.

$stateRegistry: StateRegistry

The State Registry

The State Registry

The StateRegistry singleton as a Service Object (injectable during runtime).

This service is used to register/deregister states. It has state registration related APIs including:

  • Register/deregister states
  • Listen for state registration/deregistration
  • Get states by name
  • Add state decorators (to customize the state creation process)

Note: This object is also exposed as $stateRegistryProvider for injection during the config phase.

$stateRegistryProvider: StateRegistry

The State Registry

The State Registry

The StateRegistry singleton as a Provider Object (injectable during config time).

This service is used to register/deregister states. It has state registration related APIs including:

  • Register/deregister states
  • Listen for state registration/deregistration
  • Get states by name
  • Add state decorators (to customize the state creation process)

Note: This object is also exposed as $stateRegistry for injection during runtime.

$trace: Trace

Transition debug/tracing

Transition debug/tracing

The Trace singleton as a Service Object (injectable during runtime).

Enables or disables Transition tracing which can help to debug issues.

$transition$: Transition

The current Transition object

The current Transition object

The current Transition object as a Per-Transition Object (injectable into Resolve, Hooks, Controllers)

This object returns information about the current transition, including:

  • To/from states
  • To/from parameters
  • Transition options
  • States being entered, exited, and retained
  • Resolve data
  • A Promise for the transition
  • Any transition failure information
  • An injector for both Service and Per-Transition Objects
$transitions: TransitionService

The Transition Service

The Transition Service

The TransitionService singleton as a Service Object (injectable during runtime).

This angular service exposes the TransitionService singleton, which is primarily used to register global transition hooks.

Note: This object is also exposed as $transitionsProvider for injection during the config phase.

$transitionsProvider: TransitionService

The Transition Service

The Transition Service

The TransitionService singleton as a Provider Object (injectable during config phase)

This angular service exposes the TransitionService singleton, which is primarily used to register global transition hooks.

Note: This object is also exposed as $transitions for injection during runtime.

$uiRouter: UIRouter

The UI-Router instance

The UI-Router instance

The UIRouter singleton (the router instance) as a Service Object (injectable during runtime).

This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap. It has references to the other UI-Router services

Note: This object is also exposed as $uiRouterProvider for injection during angular config time.

$uiRouterGlobals: UIRouterGlobals

Global UI-Router variables

Global UI-Router variables

The router global state as a Service Object (injectable during runtime).

This object contains globals such as the current state and current parameter values.

$uiRouterProvider: UIRouter

The UI-Router instance

The UI-Router instance

The UIRouter singleton (the router instance) as a Provider Object (injectable during config phase).

This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap. It has references to the other UI-Router services

Note: This object is also exposed as $uiRouter for injection during runtime.

$uiViewScroll: function

The View Scroll function

The View Scroll function

The View Scroll function as a Service Object (injectable during runtime).

This is a function that scrolls an element into view. The element is scrolled after a $timeout so the DOM has time to refresh.

If you prefer to rely on $anchorScroll to scroll the view to the anchor, this can be enabled by calling UIViewScrollProvider.useAnchorScroll.

Note: this function is used by the directives.uiView when the autoscroll expression evaluates to true.

Type declaration

    • ($element: JQuery): void
    • Parameters

      • $element JQuery

      Returns void

$uiViewScrollProvider: UIViewScrollProvider

The View Scroll provider

The View Scroll provider

The UIViewScrollProvider as a Provider Object (injectable during config time).

This angular service exposes the UIViewScrollProvider singleton and is used to disable UI-Router's scroll behavior.

$urlMatcherFactory: UrlMatcherFactory

The URL Matcher Factory

The URL Matcher Factory

Deprecation warning: This object is now considered internal. Use $urlService instead.

The UrlMatcherFactory singleton as a Service Object (injectable during runtime).

This service is used to set url mapping options, define custom parameter types, and create UrlMatcher objects.

Note: This object is also exposed as $urlMatcherFactoryProvider for injection during angular config time.

deprecated
$urlMatcherFactoryProvider: UrlMatcherFactory

The URL Matcher Factory

The URL Matcher Factory

Deprecation warning: This object is now considered internal. Use $urlService instead.

The UrlMatcherFactory singleton as a Provider Object (injectable during config time).

This service is used to set url mapping options, define custom parameter types, and create UrlMatcher objects.

Note: This object is also exposed as $urlMatcherFactory for injection during runtime.

deprecated
$urlRouter: UrlRouter

The Url Router

The Url Router

Deprecation warning: This object is now considered internal. Use $urlService instead.

The UrlRouter singleton as a Service Object (injectable during runtime).

Note: This object is also exposed as $urlRouterProvider for injection during angular config time.

deprecated
$urlRouterProvider: UrlRouterProvider

The URL Router Provider

The URL Router Provider

Deprecation warning: This object is now considered internal. Use $urlServiceProvider instead.

The UrlRouter singleton as a Provider Object (injectable during config time).

Note: This object is also exposed as $urlRouter for injection during runtime.

deprecated
$urlService: UrlService

The URL Service

The URL Service

The UrlService singleton as a Service Object (injectable during runtime).

Note: This service can also be injected during the config phase as $urlServiceProvider.

Used to configure the URL. It has URL related APIs including:

Note: This service can also be injected during the config phase as $urlServiceProvider.
$urlServiceProvider: UrlService

The URL Service Provider

The URL Service Provider

The UrlService singleton as a Provider Object (injectable during the angular config phase).

A service used to configure and interact with the URL. It has URL related APIs including:

Note: This service can also be injected during runtime as $urlService.

Generated using TypeDoc