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

Function directiveMetadata

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

Source from the content-addressed store, hash-verified

377 * `Component`).
378 */
379export function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMetadataFacade {
380 // Reflect inputs and outputs.
381 const reflect = getReflect();
382 const propMetadata = reflect.ownPropMetadata(type);
383
384 return {
385 name: type.name,
386 // g3-only legacyOptionalChaining: true,
387 legacyOptionalChaining: false, // 3p-only
388 type: type,
389 selector: metadata.selector !== undefined ? metadata.selector : null,
390 host: metadata.host || EMPTY_OBJ,
391 propMetadata: propMetadata,
392 inputs: metadata.inputs || EMPTY_ARRAY,
393 outputs: metadata.outputs || EMPTY_ARRAY,
394 queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
395 lifecycle: {usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges')},
396 // Indicate that this directive requires the `ɵɵcontrolCreate` instruction to be generated.
397 controlCreate: reflect.hasLifecycleHook(type, 'ɵngControlCreate')
398 ? {passThroughInput: null}
399 : null,
400 typeSourceSpan: null!,
401 usesInheritance: !extendsDirectlyFromObject(type),
402 exportAs: extractExportAs(metadata.exportAs),
403 providers: metadata.providers || null,
404 viewQueries: extractQueriesMetadata(type, propMetadata, isViewQuery),
405 isStandalone: metadata.standalone === undefined ? true : !!metadata.standalone,
406 isSignal: !!metadata.signals,
407 hostDirectives:
408 metadata.hostDirectives?.map((directive) =>
409 typeof directive === 'function' ? {directive} : directive,
410 ) || null,
411 };
412}
413
414/**
415 * 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