/** * @license * Copyright Google LLC 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 */ import { createInjector } from './create_injector'; import { THROW_IF_NOT_FOUND, ɵɵinject } from './injector_compatibility'; import { INJECTOR } from './injector_token'; import { ɵɵdefineInjectable } from './interface/defs'; import { NullInjector } from './null_injector'; /** * Concrete injectors implement this interface. Injectors are configured * with [providers](guide/glossary#provider) that associate * dependencies of various types with [injection tokens](guide/glossary#di-token). * * @see ["DI Providers"](guide/dependency-injection-providers). * @see {@link StaticProvider} * * @usageNotes * * The following example creates a service injector instance. * * {@example core/di/ts/provider_spec.ts region='ConstructorProvider'} * * ### Usage example * * {@example core/di/ts/injector_spec.ts region='Injector'} * * `Injector` returns itself when given `Injector` as a token: * * {@example core/di/ts/injector_spec.ts region='injectInjector'} * * @publicApi */ export class Injector { static { this.THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND; } static { this.NULL = ( /* @__PURE__ */new NullInjector()); } static create(options, parent) { if (Array.isArray(options)) { return createInjector({ name: '' }, parent, options, ''); } else { const name = options.name ?? ''; return createInjector({ name }, options.parent, options.providers, name); } } /** @nocollapse */ static { this.ɵprov = ɵɵdefineInjectable({ token: Injector, providedIn: 'any', factory: () => ɵɵinject(INJECTOR), }); } /** * @internal * @nocollapse */ static { this.__NG_ELEMENT_ID__ = -1 /* InjectorMarkers.Injector */; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5qZWN0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb3JlL3NyYy9kaS9pbmplY3Rvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFHSCxPQUFPLEVBQUMsY0FBYyxFQUFDLE1BQU0sbUJBQW1CLENBQUM7QUFDakQsT0FBTyxFQUFDLGtCQUFrQixFQUF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