The parent control.
A control is marked pristine
unless the user has triggered
a change
event on it.
The validation status of the control. There are four possible validation statuses:
These statuses are mutually exclusive, so a control cannot be both valid AND invalid or invalid AND disabled.
A control is marked touched
once the user has triggered
a blur
event on it.
A control is marked pristine
once the user has triggered
a change
event on it.
A control is disabled
when its status === DISABLED
.
Disabled controls are exempt from validation checks and are not included in the aggregate value of their ancestor controls.
A control is enabled
as long as its status !== DISABLED
.
In other words, it has a status of VALID
, INVALID
, or
PENDING
.
A control is invalid
when its status === INVALID
.
In order to have this status, the control must have failed at least one of its validation checks.
Retrieves the top-level ancestor of this control.
A control is untouched
if the user has not yet triggered
a blur
event on it.
A control is valid
when its status === VALID
.
In order to have this status, the control must have passed all its validation checks.
Add a control to this group.
Empties out the sync validator list.
Check whether there is an enabled control with the given name in the group.
It will return false for disabled controls. If you'd like to check for existence in the group only, use {@link AbstractControl#get get} instead.
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
.
If the control has children, all children will be disabled to maintain the model.
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.
If the control has children, all children will be enabled.
Retrieves a child control given the control's name or path.
Paths can be passed in as an array or a string delimited by a dot.
To get a control nested within a person
sub-group:
this.form.get('person.name');
-OR-
this.form.get(['person', 'name']);
Returns error data if the control with the given path has the error specified. Otherwise returns null or undefined.
If no path is given, it checks for the error on the present control.
Returns true if the control with the given path has the error specified. Otherwise returns false.
If no path is given, it checks for the error on the present control.
Marks the control as untouched
.
If the control has any children, it will also mark all children as untouched
to maintain the model, and re-calculate the touched
status of all parent
controls.
Marks the control as touched
.
This will also mark all direct ancestors as touched
to maintain
the model.
Marks the control as touched
.
This will also mark all direct ancestors as touched
to maintain
the model.
Marks the control as untouched
.
If the control has any children, it will also mark all children as untouched
to maintain the model, and re-calculate the touched
status of all parent
controls.
Patches the value of the FormGroup
. It accepts an object with control
names as keys, and will do its best to match the values to the correct controls
in the group.
It accepts both super-sets and sub-sets of the group without throwing an error.
const form = new FormGroup({
first: new FormControl(),
last: new FormControl()
})
console.log(form.value) // {first: null, last: null}
form.patchValue({first: 'Nancy'})
console.log(form.value) // {first: 'Nancy', last: null}
Registers a control with the group's list of controls.
This method does not update the value or validity of the control, so for most cases you'll want to use {@link FormGroup#addControl addControl} instead.
Remove a control from this group.
Remove errors on a form control.
This is used when validations are run manually by the user, rather than automatically.
Replace an existing control.
Sets errors on a form control.
This is used when validations are run manually by the user, rather than automatically.
Sets the synchronous validators that are active on this control.
Sets the value of the FormGroup
. It accepts an object that matches
the structure of the group, with control names as keys.
const form = new FormGroup({
first: new FormControl(),
last: new FormControl()
})
console.log(form.value) // {first: null, last: null}
form.setValue({first: 'Nancy', last: 'Drew'})
console.log(form.value) // {first: 'Nancy', last: 'Drew'}
Re-calculates the value and validation status of the control.
By default, it will also update the value and validity of its ancestors.
Generated using TypeDoc
Returns any errors generated by failing validation. If there are no errors, it will return null.