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

Function addDirectiveFactoryDef

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

Source from the content-addressed store, hash-verified

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