Function

resolveDynamicValue

@ng-forge/dynamic-forms

Normalises a {@link DynamicValue} into a Signal<T>.

Accepts a static value, a Signal<T>, or an Observable<T>. The result is a Signal<T> that reactively reflects the current value, suitable for direct use in Angular templates.

Static values yield a computed that always returns the same constant — preferable to wrapping in signal() because the computed never causes change-detection invalidation.

Pass an injector when calling outside an Angular injection context (e.g., from inside a computed). toSignal needs a DestroyRef to unsubscribe — without an injector it falls back to inject(DestroyRef), which throws when called outside injection context.

Signature

function resolveDynamicValue<
  T
>(
  value: DynamicValue<T> | undefined,
  fallback: T,
  injector?: Injector | undefined
): Signal<T>

Type Parameters

NameConstraintDefaultDescription
T---

Parameters

NameTypeDescription
valueDynamicValue<T> | undefined-
fallbackT-
injector?Injector | undefined-

Returns

Signal<T>

Examples

const isHidden = resolveDynamicValue(addon().hidden, false);
// template: \@if (isHidden()) { ... }