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

Method get

packages/forms/signals/src/field/metadata.ts:63–81  ·  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

61
62 /** Gets the value of an `MetadataKey` for the field. */
63 get<T>(key: MetadataKey<T, unknown, unknown>): T | undefined {
64 // We create non-managed metadata lazily, the first time they are accessed.
65 if (this.has(key)) {
66 if (!this.metadata.has(key)) {
67 if (key.create) {
68 throw new RuntimeError(
69 RuntimeErrorCode.MANAGED_METADATA_LAZY_CREATION,
70 ngDevMode && 'Managed metadata cannot be created lazily',
71 );
72 }
73 const logic = this.node.logicNode.logic.getMetadata(key);
74 this.metadata.set(
75 key,
76 computed(() => logic.compute(this.node.context)),
77 );
78 }
79 }
80 return this.metadata.get(key) as T | undefined;
81 }
82
83 /** Checks whether the current metadata state has the given metadata key. */
84 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