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

Function directiveMetadata

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

Source from the content-addressed store, hash-verified

370 * `Component`).
371 */
372export function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMetadataFacade {
373 // Reflect inputs and outputs.
374 const reflect = getReflect();
375 const propMetadata = reflect.ownPropMetadata(type);
376
377 return {
378 name: type.name,
379 // g3-only legacyOptionalChaining: true,
380 legacyOptionalChaining: false, // 3p-only
381 type: type,
382 selector: metadata.selector !== undefined ? metadata.selector : null,
383 host: metadata.host || EMPTY_OBJ,
384 propMetadata: propMetadata,
385 inputs: metadata.inputs || EMPTY_ARRAY,
386 outputs: metadata.outputs || EMPTY_ARRAY,
387 queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
388 lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
389 // Indicate that this directive requires the `ɵɵcontrolCreate` instruction to be generated.
390 controlCreate: reflect.hasLifecycleHook(type, 'ɵngControlCreate')
391 ? {passThroughInput: null}
392 : null,
393 typeSourceSpan: null!,
394 usesInheritance: !extendsDirectlyFromObject(type),
395 exportAs: extractExportAs(metadata.exportAs),
396 providers: metadata.providers || null,
397 viewQueries: extractQueriesMetadata(type, propMetadata, isViewQuery),
398 isStandalone: metadata.standalone === undefined ? true : !!metadata.standalone,
399 isSignal: !!metadata.signals,
400 hostDirectives:
401 metadata.hostDirectives?.map((directive) =>
402 typeof directive === 'function' ? {directive} : directive,
403 ) || null,
404 };
405}
406
407/**
408 * Adds a directive definition to all parent classes of a type that don't have an Angular decorator.

Callers 3

directive_spec.tsFile · 0.90
compileComponentFunction · 0.85
getDirectiveMetadataFunction · 0.85

Calls 7

getReflectFunction · 0.90
extractQueriesMetadataFunction · 0.85
extractExportAsFunction · 0.85
ownPropMetadataMethod · 0.80
mapMethod · 0.80
hasLifecycleHookMethod · 0.65

Tested by

no test coverage detected