Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { Type } from '../type';
9
import { InjectionToken } from './injection_token';
10
export declare const THROW_IF_NOT_FOUND: Object;
11
/**
12
 * @whatItDoes Injector interface
13
 * @howToUse
14
 * ```
15
 * const injector: Injector = ...;
16
 * injector.get(...);
17
 * ```
18
 *
19
 * @description
20
 * For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
21
 *
22
 * ### Example
23
 *
24
 * {@example core/di/ts/injector_spec.ts region='Injector'}
25
 *
26
 * `Injector` returns itself when given `Injector` as a token:
27
 * {@example core/di/ts/injector_spec.ts region='injectInjector'}
28
 *
29
 * @stable
30
 */
31
export declare abstract class Injector {
32
    static THROW_IF_NOT_FOUND: Object;
33
    static NULL: Injector;
34
    /**
35
     * Retrieves an instance from the injector based on the provided token.
36
     * If not found:
37
     * - Throws an error if no `notFoundValue` that is not equal to
38
     * Injector.THROW_IF_NOT_FOUND is given
39
     * - Returns the `notFoundValue` otherwise
40
     */
41
    abstract get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T): T;
42
    /**
43
     * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
44
     * @suppress {duplicate}
45
     */
46
    abstract get(token: any, notFoundValue?: any): any;
47
}
(3-3/9)