# Class FormDirective<T>

#### Type Parameters

- T = any

#### Hierarchy

- FormGroupDirective
  - FormDirective

#### Implements

- OnInit
- OnChanges
- OnDestroy

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:113

#####
Index

### Constructors

constructor

### Properties

_formDefinition
cdr
context
directives
form
formDefinitionBuilder
initial?
invalidSubmit
loaded$
loadFailedMethod
loading$
loadingError$
loadingIndicatorService
loadMethod
loadSuccessfulMethod
name
ngSubmit
rxapSubmit
submitError$
submitFailedMethod
submitMethod
submitSuccessful$
submitSuccessfulMethod
submitting$
ɵdir
ɵfac

### Accessors

asyncValidator
control
dirty
disabled
enabled
errors
formDefinition
formDirective
invalid
loaded
loading
loadingError
path
pending
pristine
status
statusChanges
submitError
submitted
submitting
touched
untouched
useFormDefinition
valid
validator
value
valueChanges

### Methods

addControl
addFormArray
addFormGroup
getControl
getError
getFormArray
getFormGroup
getSubmitValue
hasError
loadFailed
loadInitialState
loadSuccessful
ngOnChanges
ngOnDestroy
ngOnInit
onReset
onSubmit
removeControl
removeFormArray
removeFormGroup
reset
resetForm
submit
submitFailed
submitSuccessful
updateModel

##
Constructors

### constructor

- new FormDirective<T = any>(
  cdr: ChangeDetectorRef,
  formDefinition?: null | FormDefinition<any, any, any>,
  submitMethod?: null | FormSubmitMethod<any>,
  loadMethod?: null | FormLoadMethod<any>,
  loadFailedMethod?: null | FormLoadFailedMethod,
  loadSuccessfulMethod?: null | FormLoadSuccessfulMethod<any>,
  submitFailedMethod?: null | FormSubmitFailedMethod,
  submitSuccessfulMethod?: null | FormSubmitSuccessfulMethod<any>,
  formDefinitionBuilder?: null | RxapFormBuilder<any, FormType<any>>,
  loadingIndicatorService?: null | LoadingIndicatorService,
  ): FormDirective<T>

  #### Type Parameters

  - T = any

  #### Parameters

  - cdr: ChangeDetectorRef
  - formDefinition: null | FormDefinition<any, any, any> = null
  - submitMethod: null | FormSubmitMethod<any> = null
  - loadMethod: null | FormLoadMethod<any> = null
  - loadFailedMethod: null | FormLoadFailedMethod = null
  - loadSuccessfulMethod: null | FormLoadSuccessfulMethod<any> = null
  - submitFailedMethod: null | FormSubmitFailedMethod = null
  - submitSuccessfulMethod: null | FormSubmitSuccessfulMethod<any> = null
  - formDefinitionBuilder: null | RxapFormBuilder<any, FormType<any>> = null
  - loadingIndicatorService: null | LoadingIndicatorService = null

  #### Returns FormDirective<T>

  Overrides FormGroupDirective.constructor

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:205

##
Properties

### `Protected`_formDefinition

_formDefinition: FormDefinition<T>

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:183

### `Readonly` cdr

cdr: ChangeDetectorRef

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:206

### `Readonly` context

context: InputSignal<Record<string, unknown>> = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:121

### directives

directives: FormControlName[]

#### Description

Tracks the list of added `FormControlName` instances

Inherited from FormGroupDirective.directives

- Defined in node_modules/@angular/forms/index.d.ts:2909

### form

form: RxapFormGroup<T>

#### Description

Tracks the `FormGroup` bound to this directive.

Overrides FormGroupDirective.form

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:116

### `Protected` `Readonly` formDefinitionBuilder

formDefinitionBuilder: null | RxapFormBuilder<any, FormType<any>> = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:244

### `Optional` initial

initial?: T

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:119

### invalidSubmit

invalidSubmit: EventEmitter<Record<string, any>> = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:134

### `Readonly` loaded$

loaded$: ToggleSubject = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:180

### loadFailedMethod

loadFailedMethod: null | FormLoadFailedMethod = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:192

### `Readonly` loading$

loading$: ToggleSubject = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:179

### `Readonly` loadingError$

loadingError$: BehaviorSubject<null | Error> = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:181

### `Protected` `Readonly` loadingIndicatorService

loadingIndicatorService: null | LoadingIndicatorService = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:247

### loadMethod

loadMethod: null | FormLoadMethod<any> = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:189

### loadSuccessfulMethod

loadSuccessfulMethod: null | FormLoadSuccessfulMethod<any> = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:195

### name

name: null | string | number

#### Description

The name for the control

Inherited from FormGroupDirective.name

- Defined in node_modules/@angular/forms/index.d.ts:1201

### ngSubmit

ngSubmit: EventEmitter<any>

#### Description

Emits an event when the form submission has been triggered.

Inherited from FormGroupDirective.ngSubmit

- Defined in node_modules/@angular/forms/index.d.ts:2919

### rxapSubmit

rxapSubmit: EventEmitter<any> = ...

Emits when the submit method is executed without errors. The result of the submit method is passed as event object.

If no submit method is defined then emit after the submit button is clicked.

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:131

### `Readonly` submitError$

submitError$: BehaviorSubject<null | Error> = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:178

### submitFailedMethod

submitFailedMethod: null | FormSubmitFailedMethod = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:198

### submitMethod

submitMethod: null | FormSubmitMethod<any> = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:186

### submitSuccessful$

submitSuccessful$: EventEmitter<any> = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:138

### submitSuccessfulMethod

submitSuccessfulMethod: null | FormSubmitSuccessfulMethod<any> = null

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:201

### `Readonly` submitting$

submitting$: ToggleSubject = ...

- Defined in packages/angular/forms/src/lib/directives/form.directive.ts:177

### `Static` ɵdir

"ɵdir": unknown

Inherited from FormGroupDirective.ɵdir

- Defined in node_modules/@angular/forms/index.d.ts:3035

### `Static` ɵfac

"ɵfac": unknown

Inherited from FormGroupDirective.ɵfac

- Defined in node_modules/@angular/forms/index.d.ts:3034

##
Accessors

### asyncValidator

- get asyncValidator(): null | AsyncValidatorFn

  #### Returns null | AsyncValidatorFn

  #### Description

  Asynchronous validator function composed of all the asynchronous validators registered with this directive.

  Inherited from FormGroupDirective.asyncValidator

  - Defined in node_modules/@angular/forms/index.d.ts:822

### control

- get control(): FormGroup

  #### Returns FormGroup

  #### Description

  Returns the `FormGroup` bound to this directive.

  Inherited from FormGroupDirective.control

  - Defined in node_modules/@angular/forms/index.d.ts:2934

### dirty

- get dirty(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is dirty, meaning that the user has changed the value in the UI. If the control is not present, null is returned.

  Inherited from FormGroupDirective.dirty

  - Defined in node_modules/@angular/forms/index.d.ts:762

### disabled

- get disabled(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is disabled, meaning that the control is disabled in the UI and is exempt from validation checks and excluded from aggregate values of ancestor controls. If the control is not present, null is returned.

  Inherited from FormGroupDirective.disabled

  - Defined in node_modules/@angular/forms/index.d.ts:739

### enabled

- get enabled(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is enabled, meaning that the control is included in ancestor calculations of validity or value. If the control is not present, null is returned.

  Inherited from FormGroupDirective.enabled

  - Defined in node_modules/@angular/forms/index.d.ts:745

### errors

- get errors(): null | ValidationErrors

  #### Returns null | ValidationErrors

  #### Description

  Reports the control's validation errors. If the control is not present, null is returned.

  Inherited from FormGroupDirective.errors

  - Defined in node_modules/@angular/forms/index.d.ts:750

### formDefinition

- get formDefinition(): FormDefinition<T>

  #### Returns FormDefinition<T>

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:173

### formDirective

- get formDirective(): Form

  #### Returns Form

  #### Description

  Returns this directive's instance.

  Inherited from FormGroupDirective.formDirective

  - Defined in node_modules/@angular/forms/index.d.ts:2929

### invalid

- get invalid(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is invalid, meaning that an error exists in the input value. If the control is not present, null is returned.

  Inherited from FormGroupDirective.invalid

  - Defined in node_modules/@angular/forms/index.d.ts:725

### loaded

- get loaded(): boolean

  #### Returns boolean

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:156

### loading

- get loading(): boolean

  #### Returns boolean

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:151

### loadingError

- get loadingError(): null | Error

  #### Returns null | Error

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:161

### path

- get path(): string[]

  #### Returns string[]

  #### Description

  Returns an array representing the path to this group. Because this directive always lives at the top level of a form, it always an empty array.

  Inherited from FormGroupDirective.path

  - Defined in node_modules/@angular/forms/index.d.ts:2940

### pending

- get pending(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether a control is pending, meaning that async validation is occurring and errors are not yet available for the input value. If the control is not present, null is returned.

  Inherited from FormGroupDirective.pending

  - Defined in node_modules/@angular/forms/index.d.ts:732

### pristine

- get pristine(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is pristine, meaning that the user has not yet changed the value in the UI. If the control is not present, null is returned.

  Inherited from FormGroupDirective.pristine

  - Defined in node_modules/@angular/forms/index.d.ts:756

### status

- get status(): null | string

  #### Returns null | string

  #### Description

  Reports the validation status of the control. Possible values include: 'VALID', 'INVALID', 'DISABLED', and 'PENDING'. If the control is not present, null is returned.

  Inherited from FormGroupDirective.status

  - Defined in node_modules/@angular/forms/index.d.ts:775

### statusChanges

- get statusChanges(): null | Observable<any>

  #### Returns null | Observable<any>

  #### Description

  Returns a multicasting observable that emits a validation status whenever it is calculated for the control. If the control is not present, null is returned.

  Inherited from FormGroupDirective.statusChanges

  - Defined in node_modules/@angular/forms/index.d.ts:787

### submitError

- get submitError(): null | Error

  #### Returns null | Error

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:146

### submitted

- get submitted(): boolean

  #### Returns boolean

  #### Description

  Reports whether the form submission has been triggered.

  Inherited from FormGroupDirective.submitted

  - Defined in node_modules/@angular/forms/index.d.ts:2892
- set submitted(value: boolean): void

  #### Parameters

  - value: boolean

  #### Returns void

  Inherited from FormGroupDirective.submitted

  - Defined in node_modules/@angular/forms/index.d.ts:2893

### submitting

- get submitting(): boolean

  #### Returns boolean

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:141

### touched

- get touched(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is touched, meaning that the user has triggered a `blur` event on it. If the control is not present, null is returned.

  Inherited from FormGroupDirective.touched

  - Defined in node_modules/@angular/forms/index.d.ts:768

### untouched

- get untouched(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is untouched, meaning that the user has not yet triggered a `blur` event on it. If the control is not present, null is returned.

  Inherited from FormGroupDirective.untouched

  - Defined in node_modules/@angular/forms/index.d.ts:781

### useFormDefinition

- set useFormDefinition(value: "" | FormDefinition<T, any, any>): void

  #### Parameters

  - value: "" | FormDefinition<T, any, any>

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:166

### valid

- get valid(): null | boolean

  #### Returns null | boolean

  #### Description

  Reports whether the control is valid. A control is considered valid if no validation errors exist with the current value. If the control is not present, null is returned.

  Inherited from FormGroupDirective.valid

  - Defined in node_modules/@angular/forms/index.d.ts:719

### validator

- get validator(): null | ValidatorFn

  #### Returns null | ValidatorFn

  #### Description

  Synchronous validator function composed of all the synchronous validators registered with this directive.

  Inherited from FormGroupDirective.validator

  - Defined in node_modules/@angular/forms/index.d.ts:816

### value

- get value(): any

  #### Returns any

  #### Description

  Reports the value of the control if it is present, otherwise null.

  Inherited from FormGroupDirective.value

  - Defined in node_modules/@angular/forms/index.d.ts:712

### valueChanges

- get valueChanges(): null | Observable<any>

  #### Returns null | Observable<any>

  #### Description

  Returns a multicasting observable of value changes for the control that emits every time the value of the control changes in the UI or programmatically. If the control is not present, null is returned.

  Inherited from FormGroupDirective.valueChanges

  - Defined in node_modules/@angular/forms/index.d.ts:794

##
Methods

### addControl

- addControl(dir: FormControlName): FormControl

  #### Parameters

  - dir: FormControlName

    The `FormControlName` directive instance.

  #### Returns FormControl

  #### Description

  Method that sets up the control directive in this group, re-calculates its value and validity, and adds the instance to the internal list of directives.

  Inherited from FormGroupDirective.addControl

  - Defined in node_modules/@angular/forms/index.d.ts:2948

### addFormArray

- addFormArray(dir: FormArrayName): void

  Performs the necessary setup when a `FormArrayName` directive instance is added to the view.

  #### Parameters

  - dir: FormArrayName

    The `FormArrayName` directive instance.

  #### Returns void

  Inherited from FormGroupDirective.addFormArray

  - Defined in node_modules/@angular/forms/index.d.ts:2988

### addFormGroup

- addFormGroup(dir: FormGroupName): void

  Adds a new `FormGroupName` directive instance to the form.

  #### Parameters

  - dir: FormGroupName

    The `FormGroupName` directive instance.

  #### Returns void

  Inherited from FormGroupDirective.addFormGroup

  - Defined in node_modules/@angular/forms/index.d.ts:2968

### getControl

- getControl(dir: FormControlName): FormControl

  #### Parameters

  - dir: FormControlName

    The `FormControlName` directive instance.

  #### Returns FormControl

  #### Description

  Retrieves the `FormControl` instance from the provided `FormControlName` directive

  Inherited from FormGroupDirective.getControl

  - Defined in node_modules/@angular/forms/index.d.ts:2955

### getError

- getError(errorCode: string, path?: string | (string | number)[]): any

  #### Parameters

  - errorCode: string

    The code of the error to check

  - `Optional` path: string | (string | number)[]

    A list of control names that designates how to move from the current control to the control that should be queried for errors.

  #### Returns any

  error data for that particular error. If the control or error is not present, null is returned.

  #### Description

  Reports error data for the control with the given path.

  #### Usage Notes

  For example, for the following `FormGroup`:

      form = new FormGroup({
        address: new FormGroup({ street: new FormControl() })
      });

  The path to the 'street' control from the root form would be 'address' -> 'street'.

  It can be provided to this method in one of two formats:

  1. An array of string control names, e.g. `['address', 'street']`
  2. A period-delimited list of control names in one string, e.g. `'address.street'`

  Inherited from FormGroupDirective.getError

  - Defined in node_modules/@angular/forms/index.d.ts:887

### getFormArray

- getFormArray(dir: FormArrayName): FormArray

  #### Parameters

  - dir: FormArrayName

    The `FormArrayName` directive instance.

  #### Returns FormArray

  #### Description

  Retrieves the `FormArray` for a provided `FormArrayName` directive instance.

  Inherited from FormGroupDirective.getFormArray

  - Defined in node_modules/@angular/forms/index.d.ts:3002

### getFormGroup

- getFormGroup(dir: FormGroupName): FormGroup

  #### Parameters

  - dir: FormGroupName

    The `FormGroupName` directive instance.

  #### Returns FormGroup

  #### Description

  Retrieves the `FormGroup` for a provided `FormGroupName` directive instance

  Inherited from FormGroupDirective.getFormGroup

  - Defined in node_modules/@angular/forms/index.d.ts:2982

### `Protected` getSubmitValue

- getSubmitValue(): T

  #### Returns T

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:474

### hasError

- hasError(errorCode: string, path?: string | (string | number)[]): boolean

  #### Parameters

  - errorCode: string

    The code of the error to check

  - `Optional` path: string | (string | number)[]

    A list of control names that designates how to move from the current control to the control that should be queried for errors.

  #### Returns boolean

  whether the given error is present in the control at the given path.

  If the control is not present, false is returned.

  #### Description

  Reports whether the control with the given path has the error specified.

  #### Usage Notes

  For example, for the following `FormGroup`:

      form = new FormGroup({
        address: new FormGroup({ street: new FormControl() })
      });

  The path to the 'street' control from the root form would be 'address' -> 'street'.

  It can be provided to this method in one of two formats:

  1. An array of string control names, e.g. `['address', 'street']`
  2. A period-delimited list of control names in one string, e.g. `'address.street'`

  If no path is given, this method checks for the error on the current control.

  Inherited from FormGroupDirective.hasError

  - Defined in node_modules/@angular/forms/index.d.ts:859

### `Protected` loadFailed

- loadFailed(error: Error): void

  #### Parameters

  - error: Error

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:464

### `Protected` loadInitialState

- loadInitialState(form: RxapFormGroup): void

  #### Parameters

  - form: RxapFormGroup

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:404

### `Protected` loadSuccessful

- loadSuccessful(value: any): void

  #### Parameters

  - value: any

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:454

### ngOnChanges

- ngOnChanges(changes: SimpleChanges): void

  #### Parameters

  - changes: SimpleChanges

  #### Returns void

  #### Nodoc

  Implementation of OnChanges.ngOnChanges

  Overrides FormGroupDirective.ngOnChanges

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:267

### ngOnDestroy

- ngOnDestroy(): void

  #### Returns void

  #### Nodoc

  Implementation of OnDestroy.ngOnDestroy

  Overrides FormGroupDirective.ngOnDestroy

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:559

### ngOnInit

- ngOnInit(): void

  A callback method that is invoked immediately after the default change detector has checked the directive's data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.

  #### Returns void

  Implementation of OnInit.ngOnInit

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:277

### onReset

- onReset(): void

  #### Returns void

  #### Description

  Method called when the "reset" event is triggered on the form.

  Inherited from FormGroupDirective.onReset

  - Defined in node_modules/@angular/forms/index.d.ts:3022

### onSubmit

- onSubmit($event: Event): boolean

  #### Parameters

  - $event: Event

    The "submit" event object

  #### Returns boolean

  #### Description

  Method called with the "submit" event is triggered on the form. Triggers the `ngSubmit` emitter to emit the "submit" event as its payload.

  Overrides FormGroupDirective.onSubmit

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:322

### removeControl

- removeControl(dir: FormControlName): void

  #### Parameters

  - dir: FormControlName

    The `FormControlName` directive instance.

  #### Returns void

  #### Description

  Removes the `FormControlName` instance from the internal list of directives

  Inherited from FormGroupDirective.removeControl

  - Defined in node_modules/@angular/forms/index.d.ts:2962

### removeFormArray

- removeFormArray(dir: FormArrayName): void

  Performs the necessary cleanup when a `FormArrayName` directive instance is removed from the view.

  #### Parameters

  - dir: FormArrayName

    The `FormArrayName` directive instance.

  #### Returns void

  Inherited from FormGroupDirective.removeFormArray

  - Defined in node_modules/@angular/forms/index.d.ts:2995

### removeFormGroup

- removeFormGroup(dir: FormGroupName): void

  Performs the necessary cleanup when a `FormGroupName` directive instance is removed from the view.

  #### Parameters

  - dir: FormGroupName

    The `FormGroupName` directive instance.

  #### Returns void

  Inherited from FormGroupDirective.removeFormGroup

  - Defined in node_modules/@angular/forms/index.d.ts:2975

### reset

- reset(value?: any): void

  #### Parameters

  - `Optional` value: any

  #### Returns void

  #### Description

  Resets the control with the provided value if the control is present.

  Inherited from FormGroupDirective.reset

  - Defined in node_modules/@angular/forms/index.d.ts:828

### resetForm

- resetForm(value?: any): void

  #### Parameters

  - `Optional` value: any

    The new value for the form.

  #### Returns void

  #### Description

  Resets the form to an initial value and resets its submitted status.

  Inherited from FormGroupDirective.resetForm

  - Defined in node_modules/@angular/forms/index.d.ts:3029

### `Protected` submit

- submit(): void

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:488

### `Protected` submitFailed

- submitFailed(error: Error): void

  #### Parameters

  - error: Error

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:534

### `Protected` submitSuccessful

- submitSuccessful(value: any): void

  #### Parameters

  - value: any

  #### Returns void

  - Defined in packages/angular/forms/src/lib/directives/form.directive.ts:547

### updateModel

- updateModel(dir: FormControlName, value: any): void

  Sets the new value for the provided `FormControlName` directive.

  #### Parameters

  - dir: FormControlName

    The `FormControlName` directive instance.

  - value: any

    The new value for the directive's control.

  #### Returns void

  Inherited from FormGroupDirective.updateModel

  - Defined in node_modules/@angular/forms/index.d.ts:3009