dynamic-forms / Variable

DEFAULT_PROPS

Injection token for form-level default props.

Default props are form-wide property defaults that are merged with field-level props. Field props take precedence over default props.

Unlike FIELD_SIGNAL_CONTEXT which is re-provided by container components (Group, Array), DEFAULT_PROPS is provided ONCE at the DynamicForm level and inherited by all children via Angular's hierarchical injector.

The token provides a Signal to enable reactivity - when config changes, mappers that read the signal inside their computed() will automatically update.

Presentation

const DEFAULT_PROPS: InjectionToken<
  Signal<Record<string, unknown> | undefined>
>;

Example usage

// In a mapper function
const defaultPropsSignal = inject(DEFAULT_PROPS);

return computed(() => {
  const defaultProps = defaultPropsSignal?.();  // Read inside computed for reactivity
  const baseInputs = buildBaseInputs(fieldDef, defaultProps);
  // ...
});