W3cubDocs

/Angular

NonNullableFormBuilder

class

NonNullableFormBuilder is similar to FormBuilder, but automatically constructed FormControl elements have {nonNullable: true} and are non-nullable.

abstract class NonNullableFormBuilder {
  abstract group<T extends {}>(controls: T, options?: AbstractControlOptions): FormGroup<{...}
  abstract record<T>(controls: { [key: string]: T; }, options?: AbstractControlOptions): FormRecord<ɵElement<T, never>>
  abstract array<T>(controls: T[], validatorOrOpts?: ValidatorFn | AbstractControlOptions | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormArray<ɵElement<T, never>>
  abstract control<T>(formState: T | FormControlState<T>, validatorOrOpts?: ValidatorFn | AbstractControlOptions | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T>
}

Provided in

  • 'root'

Methods

Similar to FormBuilder#group, except any implicitly constructed FormControl will be non-nullable (i.e. it will have nonNullable set to true). Note that already-constructed controls will not be altered.

abstract group<T extends {}>(controls: T, options?: AbstractControlOptions): FormGroup<{ [K in keyof T]: ɵElement<T[K], never>; }>

Parameters
controls T
options AbstractControlOptions

Optional. Default is undefined.

Returns

FormGroup<{ [K in keyof T]: ɵElement<T[K], never>; }>

Similar to FormBuilder#record, except any implicitly constructed FormControl will be non-nullable (i.e. it will have nonNullable set to true). Note that already-constructed controls will not be altered.

abstract record<T>(controls: { [key: string]: T; }, options?: AbstractControlOptions): FormRecord<ɵElement<T, never>>

Parameters
controls object
options AbstractControlOptions

Optional. Default is undefined.

Returns

FormRecord<ɵElement<T, never>>

Similar to FormBuilder#array, except any implicitly constructed FormControl will be non-nullable (i.e. it will have nonNullable set to true). Note that already-constructed controls will not be altered.

abstract array<T>(controls: T[], validatorOrOpts?: ValidatorFn | AbstractControlOptions | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormArray<ɵElement<T, never>>

Parameters
controls T[]
validatorOrOpts ValidatorFn | AbstractControlOptions | ValidatorFn[]

Optional. Default is undefined.

asyncValidator AsyncValidatorFn | AsyncValidatorFn[]

Optional. Default is undefined.

Returns

FormArray<ɵElement<T, never>>

Similar to FormBuilder#control, except this overridden version of control forces nonNullable to be true, resulting in the control always being non-nullable.

abstract control<T>(formState: T | FormControlState<T>, validatorOrOpts?: ValidatorFn | AbstractControlOptions | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T>

Parameters
formState T | FormControlState<T>
validatorOrOpts ValidatorFn | AbstractControlOptions | ValidatorFn[]

Optional. Default is undefined.

asyncValidator AsyncValidatorFn | AsyncValidatorFn[]

Optional. Default is undefined.

Returns

FormControl<T>

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/forms/NonNullableFormBuilder