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

Method get

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

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