/** * @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 { InjectFlags, resolveForwardRef } from '../../di'; import { assertInjectImplementationNotEqual } from '../../di/inject_switch'; import { ɵɵinject } from '../../di/injector_compatibility'; import { emitInjectEvent } from '../debug/injector_profiler'; import { getOrCreateInjectable } from '../di'; import { getCurrentTNode, getLView } from '../state'; export function ɵɵdirectiveInject(token, flags = InjectFlags.Default) { const lView = getLView(); // Fall back to inject() if view hasn't been created. This situation can happen in tests // if inject utilities are used before bootstrapping. if (lView === null) { // Verify that we will not get into infinite loop. ngDevMode && assertInjectImplementationNotEqual(ɵɵdirectiveInject); return ɵɵinject(token, flags); } const tNode = getCurrentTNode(); const value = getOrCreateInjectable(tNode, lView, resolveForwardRef(token), flags); ngDevMode && emitInjectEvent(token, value, flags); return value; } /** * Throws an error indicating that a factory function could not be generated by the compiler for a * particular class. * * This instruction allows the actual error message to be optimized away when ngDevMode is turned * off, saving bytes of generated code while still providing a good experience in dev mode. * * The name of the class is not mentioned here, but will be in the generated factory function name * and thus in the stack trace. * * @codeGenApi */ export function ɵɵinvalidFactory() { const msg = ngDevMode ? `This constructor was not compatible with Dependency Injection.` : 'invalid'; throw new Error(msg); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb3JlL3NyYy9yZW5kZXIzL2luc3RydWN0aW9ucy9kaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxPQUFPLEVBQUMsV0FBVyxFQUFFLGlCQUFpQixFQUFDLE1BQU0sVUFBVSxDQUFDO0FBQ3hELE9BQU8sRUFBQyxrQ0FBa0MsRUFBQyxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8s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