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

Interface UIInjector

An interface for getting values from dependency injection.

Hierarchy

  • UIInjector

Index

Methods

Methods

  • get(key: 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');
    

    Note: The code that implements this interface may be Angular 1 $injector, Angular 2 Injector, a ResolveContext, or a ResolveContext that delegates to the ng1/ng2 injector if keys are missing.

    Parameters

    • key: any
      :

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

    Returns any

    :

    the Dependency Injection value that matches the key


  • getAsync(key: any): any
  • Asynchronously gets a value from the injector

  • Asynchronously gets a value from the injector

    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

    • key: any
      :

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

    Returns any

    :

    a Promise for the Dependency Injection value that matches the key


Generated using TypeDoc