Function

hasFormValue

@ng-forge/dynamic-forms

Type guard to check if a form event has a form value attached.

Use this to safely access the formValue property on events when withEventFormValue() is enabled globally or options.emitFormValueOnEvents is set to true in the form config.

Signature

function hasFormValue<
  T extends FormEvent
>(event: T): boolean

Type Parameters

NameConstraintDefaultDescription
TFormEvent--

Parameters

NameTypeDescription
eventT- The form event to check

Returns

boolean

Examples

eventBus.on<SubmitEvent>('submit').subscribe(event => {
  if (hasFormValue(event)) {
    console.log('Form value:', event.formValue);
  }
});