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

Method get

packages/forms/signals/src/field/metadata.ts:54–72  ·  view source on GitHub ↗

Gets the value of an `MetadataKey` for the field.

(key: MetadataKey<T, unknown, unknown>)

Source from the content-addressed store, hash-verified

52
53 /** Gets the value of an `MetadataKey` for the field. */
54 get<T>(key: MetadataKey<T, unknown, unknown>): T | undefined {
55 // We create non-managed metadata lazily, the first time they are accessed.
56 if (this.has(key)) {
57 if (!this.metadata.has(key)) {
58 if (key.create) {
59 throw new RuntimeError(
60 RuntimeErrorCode.MANAGED_METADATA_LAZY_CREATION,
61 ngDevMode && 'Managed metadata cannot be created lazily',
62 );
63 }
64 const logic = this.node.logicNode.logic.getMetadata(key);
65 this.metadata.set(
66 key,
67 computed(() => logic.compute(this.node.context)),
68 );
69 }
70 }
71 return this.metadata.get(key) as T | undefined;
72 }
73
74 /** Checks whether the current metadata state has the given metadata key. */
75 has(key: MetadataKey<any, any, any>): boolean {

Callers

nothing calls this directly

Calls 7

hasMethod · 0.95
computedFunction · 0.90
getMetadataMethod · 0.80
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65
computeMethod · 0.45

Tested by

no test coverage detected