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 FormEvent

Type Parameters

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

Properties

NameTypeDescription
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' }
));