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

Function directiveMetadata

packages/core/src/render3/jit/directive.ts:372–404  ·  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 legacyOptionalChaining: false,
380 type: type,
381 selector: metadata.selector !== undefined ? metadata.selector : null,
382 host: metadata.host || EMPTY_OBJ,
383 propMetadata: propMetadata,
384 inputs: metadata.inputs || EMPTY_ARRAY,
385 outputs: metadata.outputs || EMPTY_ARRAY,
386 queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
387 lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
388 // Indicate that this directive requires the `ɵɵcontrolCreate` instruction to be generated.
389 controlCreate: reflect.hasLifecycleHook(type, 'ɵngControlCreate')
390 ? {passThroughInput: null}
391 : null,
392 typeSourceSpan: null!,
393 usesInheritance: !extendsDirectlyFromObject(type),
394 exportAs: extractExportAs(metadata.exportAs),
395 providers: metadata.providers || null,
396 viewQueries: extractQueriesMetadata(type, propMetadata, isViewQuery),
397 isStandalone: metadata.standalone === undefined ? true : !!metadata.standalone,
398 isSignal: !!metadata.signals,
399 hostDirectives:
400 metadata.hostDirectives?.map((directive) =>
401 typeof directive === 'function' ? {directive} : directive,
402 ) || null,
403 };
404}
405
406/**
407 * 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…