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 FormEventType Parameters
| Name | Constraint | Default | Description |
|---|---|---|---|
TTemplate | ArrayItemDefinitionTemplate | ArrayItemDefinitionTemplate | The type of the template (single field or array of fields) |
Properties
| Name | Type | Description |
|---|---|---|
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' }
));packages/dynamic-forms/src/lib/events/constants/insert-array-item.event.ts:25