ControlArray class

Defines a part of a form, of variable length, that can contain other controls.

A ControlArray aggregates the values of each Control in the group. The status of a ControlArray depends on the status of its children. If one of the controls in a group is invalid, the entire array is invalid. Similarly, if a control changes its value, the entire array changes as well.

ControlArray is one of the three fundamental building blocks used to define forms in Angular, along with Control and ControlGroup. ControlGroup can also contain other controls, but is of fixed length.

Adding or removing controls

To change the controls in the array, use the push, insert, or removeAt methods in ControlArray itself. These methods ensure the controls are properly tracked in the form's hierarchy. Do not modify the array of AbstractControls used to instantiate the ControlArray directly, as that will result in strange and unexpected behavior such as broken change detection.

Inheritance

Constructors

ControlArray(List<AbstractControl> controls, [ValidatorFn? validator])

Properties

controls List<AbstractControl>
getter/setter pair
dirty bool
no setterinherited
disabled bool
no setterinherited
disabledChanges Stream<bool>
no setterinherited
enabled bool
no setterinherited
errors Map<String, dynamic>?
Returns the errors of this control.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
invalid bool
no setterinherited
length num
Length of the control array.
no setter
pending bool
no setterinherited
pristine bool
no setterinherited
root AbstractControl
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status ControlStatus?
The validation status of the control.
no setterinherited
statusChanges Stream<ControlStatus>
no setterinherited
touched bool
no setterinherited
untouched bool
no setterinherited
valid bool
no setterinherited
validator ValidatorFn?
getter/setter pairinherited
value List?
no setterinherited
valueChanges Stream<List?>
no setterinherited

Methods

at(int index) AbstractControl
Get the AbstractControl at the given index in the list.
find(String? path) AbstractControl?
Walks the path supplied to find matching control.
inherited
findPath(List<String?>? path) AbstractControl?
Walks the path to find the matching control.
inherited
getError(String errorCode, [List<String>? path]) → dynamic
inherited
hasError(String errorCode, [List<String>? path]) bool
inherited
insert(int index, AbstractControl control) → void
Insert a new AbstractControl at the given index in the array.
markAsDirty({bool? onlySelf, bool emitEvent = true}) → void
Mark the control as dirty.
inherited
markAsDisabled({bool updateParent = true, bool emitEvent = true}) → void
Disables the control. This means the control will be exempt from validation checks and excluded from the aggregate value of any parent. Its status is DISABLED.
inherited
markAsEnabled({bool updateParent = true, bool emitEvent = true}) → void
Enables the control. This means the control will be included in validation checks and the aggregate value of its parent. Its status is re-calculated based on its value and its validators.
inherited
markAsPending({bool onlySelf = false}) → void
inherited
markAsPristine({bool updateParent = true}) → void
Marks the control as pristine.
inherited
markAsTouched({bool updateParent = true}) → void
Marks the control as touched.
inherited
markAsUntouched({bool updateParent = true}) → void
Marks the control as untouched.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onUpdate() → void
Callback when control is asked to update its value.
override
push(AbstractControl control) → void
Insert a new AbstractControl at the end of the array.
removeAt(int index) → void
Remove the control at the given index in the array.
reset({List? value, bool? isDisabled, bool? updateParent, bool? emitEvent}) → void
Resets the form control.
inherited
setErrors(Map<String, dynamic> errors, {bool emitEvent = true}) → void
Sets errors on a control.
inherited
setParent(AbstractControl parent) → void
inherited
toString() String
A string representation of this object.
inherited
updateValue(List? value, {bool? onlySelf, bool? emitEvent, bool? emitModelToViewChange, String? rawValue}) → void
Set the value of the AbstractControl to value.
override
updateValueAndValidity({bool? onlySelf, bool? emitEvent}) → void
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited