Options
All
  • Public
  • Public/Protected
  • All
Menu

@alterior/di

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

GetterFn

GetterFn: (obj: any) => any

Type declaration

    • (obj: any): any
    • Parameters

      • obj: any

      Returns any

MethodFn

MethodFn: (obj: any, args: any[]) => any

Type declaration

    • (obj: any, args: any[]): any
    • Parameters

      • obj: any
      • args: any[]

      Returns any

ModuleLike

Provider

whatitdoes

Describes how the Injector should be configured.

howtouse

See TypeProvider, ValueProvider, ClassProvider, ExistingProvider, FactoryProvider.

description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

stable

ProviderWithDependencies

ProviderWithDependencies: Provider & ProviderDependencies

SetterFn

SetterFn: (obj: any, value: any) => void
license

Copyright Google Inc. All Rights Reserved.

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license

Type declaration

    • (obj: any, value: any): void
    • Parameters

      • obj: any
      • value: any

      Returns void

Variables

Const DELEGATE_CTOR

DELEGATE_CTOR: RegExp = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/

Attention: This regex has to hold even if the code is minified!

Const ERROR_COMPONENT_TYPE

ERROR_COMPONENT_TYPE: "ngComponentType" = "ngComponentType"

Const ERROR_DEBUG_CONTEXT

ERROR_DEBUG_CONTEXT: "ngDebugContext" = "ngDebugContext"

Const ERROR_LOGGER

ERROR_LOGGER: "ngErrorLogger" = "ngErrorLogger"

Const ERROR_ORIGINAL_ERROR

ERROR_ORIGINAL_ERROR: "ngOriginalError" = "ngOriginalError"

Const ERROR_TYPE

ERROR_TYPE: "ngType" = "ngType"
license

Copyright Google Inc. All Rights Reserved.

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license

Const Host

Host: AnnotationDecorator<[any]> = HostAnnotation.decorator({validTargets: ['parameter']})
whatitdoes

Specifies that an injector should retrieve a dependency from any injector until reaching the host element of the current component.

howtouse
@Injectable()
class Car {
  constructor(@Host() public engine:Engine) {}
}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='Host'}

stable

Const INJECTOR_KEY

INJECTOR_KEY: ReflectiveKey = ReflectiveKey.get(Injector)

Const Inject

Inject: AnnotationDecorator<[any]> = InjectAnnotation.decorator({validTargets: ['parameter', 'property']})
whatitdoes

A parameter decorator that specifies a dependency.

howtouse
@Injectable()
class Car {
  constructor(@Inject("MyEngine") public engine:Engine) {}
}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='Inject'}

When @Inject() is not present, Injector will use the type annotation of the parameter.

Example

{@example core/di/ts/metadata_spec.ts region='InjectWithoutDecorator'}

stable

Const Injectable

Injectable: AnnotationDecorator<[any]> = InjectableAnnotation.decorator({validTargets: ['class'],/*** Allow multiple because this decorator is usually applied to both superclasses* and subclasses. TODO: if we change semantics on super/subclass duplicate definitions* this should be revisited and probably removed.*/allowMultiple: true})
whatitdoes

A marker metadata that marks a class as available to Injector for creation.

howtouse
@Injectable()
class Car {}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='Injectable'}

Injector will throw {@link NoAnnotationError} when trying to instantiate a class that does not have @Injectable marker, as shown in the example below.

{@example core/di/ts/metadata_spec.ts region='InjectableThrows'}

stable

Const Module

Module: AnnotationDecorator<[ModuleOptions]> = ModuleAnnotation.decorator()

Annotation that denotes an Alterior module class.

Const Optional

Optional: AnnotationDecorator<[any]> = OptionalAnnotation.decorator({validTargets: ['parameter']})
whatitdoes

A parameter metadata that marks a dependency as optional. Injector provides null if the dependency is not found.

howtouse
@Injectable()
class Car {
  constructor(@Optional() public engine:Engine) {}
}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='Optional'}

stable

Const Self

Self: AnnotationDecorator<[any]> = SelfAnnotation.decorator({validTargets: ['parameter']})
whatitdoes

Specifies that an Injector should retrieve a dependency only from itself.

howtouse
@Injectable()
class Car {
  constructor(@Self() public engine:Engine) {}
}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='Self'}

stable

Const SkipSelf

SkipSelf: AnnotationDecorator<[any]> = SkipSelfAnnotation.decorator({validTargets: ['parameter']})
whatitdoes

Specifies that the dependency resolution should start from the parent injector.

howtouse
@Injectable()
class Car {
  constructor(@SkipSelf() public engine:Engine) {}
}
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

Example

{@example core/di/ts/metadata_spec.ts region='SkipSelf'}

stable

Const THROW_IF_NOT_FOUND

THROW_IF_NOT_FOUND: Object = _THROW_IF_NOT_FOUND

Const Type

Type: FunctionConstructor = Function
whatitdoes

Represents a type that a Component or other object is instances of.

description

An example of a Type is MyCustomComponent class, which in JavaScript is be represented by the MyCustomComponent constructor function.

stable

Const UNDEFINED

UNDEFINED: Object = new Object()

WorkerGlobalScope

WorkerGlobalScope: any

Const _EMPTY_LIST

_EMPTY_LIST: any[] = []

Const _THROW_IF_NOT_FOUND

_THROW_IF_NOT_FOUND: Object = new Object()

Const _global

_global: BrowserNodeGlobal = globalScope

Const _globalKeyRegistry

_globalKeyRegistry: KeyRegistry = new KeyRegistry()

global

global: any

Let globalScope

globalScope: BrowserNodeGlobal

Const reflector

reflector: Reflector = new Reflector(new ReflectionCapabilities())

The Reflector used internally in Angular to access metadata about symbols.

Functions

_createDependency

_dependenciesFor

_extractToken

_mapProviders

_normalizeProviders

addKey

configureModule

constructDependencies

constructResolvingPath

  • constructResolvingPath(keys: any[]): string

convertTsickleDecoratorIntoMetadata

  • convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[]

cyclicDependencyError

defaultErrorLogger

  • defaultErrorLogger(console: Console, ...values: any[]): void

findFirstClosedCycle

  • findFirstClosedCycle(keys: any[]): any[]

forwardRef

  • Allows to refer to references which are not yet defined.

    For instance, forwardRef is used when the token which we need to refer to for the purposes of DI is declared, but not yet defined. It is also used when the token which we use when creating a query is not yet defined.

    Example

    {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}

    experimental

    Parameters

    Returns Type<any>

getDebugContext

getErrorLogger

  • getErrorLogger(error: Error): (console: Console, ...values: any[]) => void

getOriginalError

getParentCtor

getType

injectionError

instantiationError

  • Thrown when a constructing type returns with an Error.

    The InstantiationError class contains the original error plus the dependency graph which caused this object to be instantiated.

    Example (live demo)

    class A {
      constructor() {
        throw new Error('message');
      }
    }
    
    var injector = Injector.resolveAndCreate([A]);
    
    try {
      injector.get(A);
    } catch (e) {
      expect(e instanceof InstantiationError).toBe(true);
      expect(e.originalException.message).toEqual("message");
      expect(e.originalStack).toBeDefined();
    }

    Parameters

    Returns InjectionError

invalidProviderError

  • invalidProviderError(provider: any): Error

isPresent

  • isPresent<T>(obj: T): obj is NonNullable<T>

isType

  • isType(v: any): v is Type<any>

mergeResolvedReflectiveProviders

mixingMultiProvidersWithRegularProvidersError

  • mixingMultiProvidersWithRegularProvidersError(provider1: any, provider2: any): Error
  • Thrown when a multi provider and a regular provider are bound to the same token.

    Example

    expect(() => Injector.resolveAndCreate([
      { provide: "Strings", useValue: "string1", multi: true},
      { provide: "Strings", useValue: "string2", multi: false}
    ])).toThrowError();

    Parameters

    • provider1: any
    • provider2: any

    Returns Error

noAnnotationError

  • Thrown when the class has no annotation information.

    Lack of annotation information prevents the Injector from determining which dependencies need to be injected into the constructor.

    Example (live demo)

    class A {
      constructor(b) {}
    }
    
    expect(() => Injector.resolveAndCreate([A])).toThrowError();

    This error is also thrown when the class not marked with Injectable has parameter types.

    class B {}
    
    class A {
      constructor(b:B) {} // no information about the parameter types of A is available at runtime.
    }
    
    expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
    stable

    Parameters

    Returns Error

noProviderError

outOfBoundsError

  • outOfBoundsError(index: number): Error

resolveForwardRef

  • resolveForwardRef(type: any): any

resolveReflectiveFactory

resolveReflectiveProvider

resolveReflectiveProviders

stringify

  • stringify(token: any): string

wrappedError

  • wrappedError(message: string, originalError: any): Error

Generated using TypeDoc