Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

NonNullableFormBuilder

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): FormRecordElement<T, never>>
abstract array<T>(controls: T[], validatorOrOpts?: ValidatorFn | AbstractControlOptions | ValidatorFn[], asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[]): FormArrayElement<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): FormRecordElement<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[]): FormArrayElement<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>