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
AbstractControl
s used to instantiate the ControlArray
directly, as that
will result in strange and unexpected behavior such as broken change
detection.
- Inheritance
- Object
- AbstractControl
- ControlArray
Constructors
- ControlArray(List<AbstractControl> controls, [ ValidatorFn validator = null, AsyncValidatorFn asyncValidator = null ])
Properties
- asyncValidator → AsyncValidatorFn
-
read / write, inherited
- controls → List<AbstractControl>
-
read / write
- dirty → bool
-
read-only, inherited
- errors → Map<String, dynamic>
-
Returns the errors of this control.
read-only, inherited - hashCode → int
-
Get a hash code for this object.
read-only, inherited - length → num
-
Length of the control array.
read-only - pending → bool
-
read-only, inherited
- pristine → bool
-
read-only, inherited
- root → AbstractControl
-
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - status → String
-
read-only, inherited
- statusChanges → Stream
-
read-only, inherited
- touched → bool
-
read-only, inherited
- untouched → bool
-
read-only, inherited
- valid → bool
-
read-only, inherited
- validator → ValidatorFn
-
read / write, inherited
- value → dynamic
-
read-only, inherited
- valueChanges → Stream
-
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
at(
num index) → AbstractControl -
Get the AbstractControl at the given
index
in the list. -
find(
path) → AbstractControl -
inherited
-
getError(
String errorCode, [ List<String> path ]) → dynamic -
inherited
-
hasError(
String errorCode, [ List<String> path = null ]) → bool -
inherited
-
insert(
num index, AbstractControl control) → void -
Insert a new AbstractControl at the given
index
in the array. -
markAsDirty(
{bool onlySelf }) → void -
inherited
-
markAsPending(
{bool onlySelf }) → void -
inherited
-
markAsTouched(
) → void -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
push(
AbstractControl control) → void -
Insert a new AbstractControl at the end of the array.
-
removeAt(
num index) → void -
Remove the control at the given
index
in the array. -
setErrors(
Map<String, dynamic> errors, { bool emitEvent }) → void -
Sets errors on a control.
inherited -
setParent(
parent) → void -
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited -
updateValueAndValidity(
{bool onlySelf, bool emitEvent }) → void -
inherited