Class

InsertArrayItemEvent

@ng-forge/dynamic-forms

Event dispatched to insert a new item at a SPECIFIC INDEX in an array field.

Use this when you need precise control over where the new item appears. For simpler operations, use {@link AppendArrayItemEvent} or {@link PrependArrayItemEvent}.

Signature

class InsertArrayItemEvent<
  TTemplate extends ArrayItemDefinitionTemplate = ArrayItemDefinitionTemplate
>
  implements FormEvent

Type Parameters

NameConstraintDefaultDescription
TTemplateArrayItemDefinitionTemplateArrayItemDefinitionTemplateThe type of the template (single field or array of fields)

Properties

NameTypeDescription
type "insert-array-item"-

Examples

// Object item: insert { name } object at index 2
eventBus.dispatch(arrayEvent('contacts').insertAt(2, [
  { key: 'name', type: 'input', label: 'Name' }
]));

// Primitive item: insert single value at index 2
eventBus.dispatch(arrayEvent('tags').insertAt(2,
  { key: 'tag', type: 'input', label: 'Tag' }
));