Attention: This regex has to hold even if the code is minified!
Annotation that denotes an Alterior module class.
The Reflector used internally in Angular to access metadata about symbols.
Thrown when dependencies form a cycle.
var injector = Injector.resolveAndCreate([
{provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
{provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
]);
expect(() => injector.get("one")).toThrowError();
Retrieving A
or B
throws a CyclicDependencyError
as the graph above cannot be constructed.
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 core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
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.
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();
}
expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
Merges a list of ResolvedProviders into a list where each key is contained exactly once and multi providers have been merged.
Thrown when a multi provider and a regular provider are bound to the same token.
expect(() => Injector.resolveAndCreate([
{ provide: "Strings", useValue: "string1", multi: true},
{ provide: "Strings", useValue: "string2", multi: false}
])).toThrowError();
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.
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();
Thrown when trying to retrieve a dependency by key from Injector, but the Injector does not have a Provider for the given key.
class A {
constructor(b:B) {}
}
expect(() => Injector.resolveAndCreate([A])).toThrowError();
Thrown when getting an object by index.
class A {}
var injector = Injector.resolveAndCreate([A]);
expect(() => injector.getAt(100)).toThrowError();
Lazily retrieves the reference value from a forwardRef.
Acts as the identity function when given a non-forward-ref value.
{@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
See: forwardRef
Resolve a single provider.
Converts the Provider into {@link ResolvedProvider}.
Injector internally only uses {@link ResolvedProvider}, Provider contains convenience provider syntax.
Resolve a list of Providers.
Generated using TypeDoc
Describes how the Injector should be configured.
See TypeProvider, ValueProvider, ClassProvider, ExistingProvider, FactoryProvider.
For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.