Function
arrayEvent
@ng-forge/dynamic-forms
Builder for array manipulation events.
Provides a fluent, discoverable API for array operations.
Type arrayEvent('key'). in your IDE to see all available operations.
Breaking Change: Template is now required for add operations.
Supports both primitive and object array items: - Primitive: Pass a single field definition → extracts field value directly - Object: Pass an array of field definitions → merges fields into object
Signature
function arrayEvent(arrayKey: string): { append: <T extends ArrayItemDefinitionTemplate>(template: T) => AppendArrayItemEvent<T>; prepend: <T extends ArrayItemDefinitionTemplate>(template: T) => PrependArrayItemEvent<T>; insertAt: <T extends ArrayItemDefinitionTemplate>(index: number, template: T) => InsertArrayItemEvent<T>; pop: () => PopArrayItemEvent; shift: () => ShiftArrayItemEvent; removeAt: (index: number) => RemoveAtIndexEvent; move: (from: number, to: number) => MoveArrayItemEvent; }Parameters
| Name | Type | Description |
|---|---|---|
arrayKey | string | - The key of the array field to operate on |
Returns
{ append: <T extends ArrayItemDefinitionTemplate>(template: T) => AppendArrayItemEvent<T>; prepend: <T extends ArrayItemDefinitionTemplate>(template: T) => PrependArrayItemEvent<T>; insertAt: <T extends ArrayItemDefinitionTemplate>(index: number, template: T) => InsertArrayItemEvent<T>; pop: () => P...
Examples
import { arrayEvent } from '@ng-forge/dynamic-forms';
// Object item: append { name, email } object
eventBus.dispatch(arrayEvent('contacts').append([
{ key: 'name', type: 'input', label: 'Name' },
{ key: 'email', type: 'input', label: 'Email' }
]));
// Primitive item: append single value
eventBus.dispatch(arrayEvent('tags').append(
{ key: 'tag', type: 'input', label: 'Tag' }
));
// Removing items (no template needed)
eventBus.dispatch(arrayEvent('contacts').pop()); // Remove last
eventBus.dispatch(arrayEvent('contacts').shift()); // Remove first
eventBus.dispatch(arrayEvent('contacts').removeAt(2)); // Remove at index
// Reordering items (no template needed, preserves item identity)
eventBus.dispatch(arrayEvent('contacts').move(0, 2)); // Move first to thirdpackages/dynamic-forms/src/lib/events/array-event.ts:48