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

Interface UIInjector

An interface for getting values from dependency injection.

This injector primarily returns resolve values (using a ResolveContext) that match the given token. If no resolve is found for a token, then it will delegate to the native injector. The native injector may be Angular 1 $injector, Angular 2 Injector, or a naive polyfill.

In Angular 2, the native injector might be the root Injector, or it might be a lazy loaded NgModule injector scoped to a lazy load state tree.

Hierarchy

  • UIInjector

Implemented by

Index

Methods

  • get(token: any): any
  • Gets a value from the injector

  • Gets a value from the injector

    example
    
    // ng1
    injector.get('$state').go('home');
    
    example
    
    // ng2
    import {StateService} from "ui-router-ng2";
    injector.get(StateService).go('home');
    

    Parameters

    • token: any
      :

      the key for the value to get. May be a string or arbitrary object.

    Returns any

    :

    the Dependency Injection value that matches the token


  • getAsync(token: any): Promise<any>
  • Asynchronously gets a value from the injector

  • Asynchronously gets a value from the injector

    If the ResolveContext has a Resolvable matching the token, it will be asynchronously resolved.

    Returns a promise for a value from the injector. Returns resolve values and/or values from the native injector (ng1/ng2).

    example
    
    return injector.getAsync('myResolve').then(value => {
      if (value === 'declined') return false;
    });
    

    Parameters

    • token: any
      :

      the key for the value to get. May be a string or arbitrary object.

    Returns Promise<any>

    :

    a Promise for the Dependency Injection value that matches the token


  • getNative(token: any): any
  • Gets a value from the native injector

  • Gets a value from the native injector

    Returns a value from the native injector, bypassing anything in the ResolveContext.

    Example:

    let someThing = injector.getNative(SomeToken);
    

    Parameters

    • token: any
      :

      the key for the value to get. May be a string or arbitrary object.

    Returns any

    :

    the Dependency Injection value that matches the token


Generated using TypeDoc