MCPcopy Create free account
hub / github.com/angular/angular / addDirectiveFactoryDef

Function addDirectiveFactoryDef

packages/core/src/render3/jit/directive.ts:344–369  ·  view source on GitHub ↗
(type: Type<any>, metadata: Directive | Component)

Source from the content-addressed store, hash-verified

342}
343
344function addDirectiveFactoryDef(type: Type<any>, metadata: Directive | Component) {
345 let ngFactoryDef: any = null;
346
347 Object.defineProperty(type, NG_FACTORY_DEF, {
348 get: () => {
349 if (ngFactoryDef === null) {
350 const meta = getDirectiveMetadata(type, metadata);
351 const compiler = getCompilerFacade({
352 usage: JitCompilerUsage.Decorator,
353 kind: 'directive',
354 type,
355 });
356 ngFactoryDef = compiler.compileFactory(angularCoreEnv, `ng:///${type.name}/ɵfac.js`, {
357 name: meta.metadata.name,
358 type: meta.metadata.type,
359 typeArgumentCount: 0,
360 deps: reflectDependencies(type),
361 target: compiler.FactoryTarget.Directive,
362 });
363 }
364 return ngFactoryDef;
365 },
366 // Make the property configurable in dev mode to allow overriding in tests
367 configurable: !!ngDevMode,
368 });
369}
370
371export function extendsDirectlyFromObject(type: Type<any>): boolean {
372 return Object.getPrototypeOf(type.prototype) === Object.prototype;

Callers 2

compileComponentFunction · 0.85
compileDirectiveFunction · 0.85

Calls 4

getCompilerFacadeFunction · 0.90
reflectDependenciesFunction · 0.90
getDirectiveMetadataFunction · 0.70
compileFactoryMethod · 0.65

Tested by

no test coverage detected