UNPKG

1.56 kBJavaScriptView Raw
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 */
8import { stringify } from './facade/lang';
9var _THROW_IF_NOT_FOUND = new Object();
10export var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
11// tslint:disable-next-line:class-name no-use-before-declare
12var _NullInjector = /** @class */ (function () {
13 function _NullInjector() {
14 }
15 _NullInjector.prototype.get = function (token, notFoundValue) {
16 if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
17 if (notFoundValue === _THROW_IF_NOT_FOUND) {
18 throw new Error("No provider for " + stringify(token) + "!");
19 }
20 return notFoundValue;
21 };
22 return _NullInjector;
23}());
24/**
25 * @whatItDoes Injector interface
26 * @howToUse
27 * ```
28 * const injector: Injector = ...;
29 * injector.get(...);
30 * ```
31 *
32 * @description
33 * For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
34 *
35 * ### Example
36 *
37 * {@example core/di/ts/injector_spec.ts region='Injector'}
38 *
39 * `Injector` returns itself when given `Injector` as a token:
40 * {@example core/di/ts/injector_spec.ts region='injectInjector'}
41 *
42 * @stable
43 */
44var Injector = /** @class */ (function () {
45 function Injector() {
46 }
47 Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
48 Injector.NULL = new _NullInjector();
49 return Injector;
50}());
51export { Injector };
52//# sourceMappingURL=injector.js.map
\No newline at end of file