Class
PrependArrayItemEvent
@ng-forge/dynamic-forms
Event dispatched to prepend a new item at the BEGINNING of an array field.
Use this when new items should appear at the start of the list. For appending to the end, use {@link AppendArrayItemEvent}.
Signature
class PrependArrayItemEvent<
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 | "prepend-array-item" | - |
Examples
// Object item: prepend { name } object
eventBus.dispatch(arrayEvent('contacts').prepend([
{ key: 'name', type: 'input', label: 'Name' }
]));
// Primitive item: prepend single value
eventBus.dispatch(arrayEvent('tags').prepend(
{ key: 'tag', type: 'input', label: 'Tag' }
));packages/dynamic-forms/src/lib/events/constants/prepend-array-item.event.ts:25