MCPcopy Index your code
hub / github.com/angular/angular / addDirectiveFactoryDef

Function addDirectiveFactoryDef

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…