dynamic-forms / Variable

ARRAY_CONTEXT

Injection token for providing array context metadata to mappers and components.

This token is optionally provided by ArrayFieldComponent when creating injectors for array items. It contains metadata about the array item's position and parent.

Mappers can inject this token with {optional: true} to access array context:

Presentation

const ARRAY_CONTEXT: InjectionToken<ArrayContext>;

Example usage

// In a mapper function
export function buttonMapper(fieldDef: FieldDef<any>): Binding[] {
  const arrayContext = inject(ARRAY_CONTEXT, { optional: true });
  if (arrayContext) {
    // Use arrayContext.index, arrayContext.arrayKey, etc.
  }
}