Angular 9 References/ Forms
References

AbstractControlDirective

This is the documentation for Angular 9.
You can switch to the latest version Angular 10.

Base class for control directives.

This class is only used internally in the ReactiveFormsModule and the FormsModule.

Subclasses

Interface

control#

get control(): AbstractControl|null
A reference to the underlying control. Returns the control that backs this directive. Most properties fall through to that instance.

value#

get value(): any
Reports the value of the control if it is present, otherwise null.

valid#

get valid(): boolean|null
Reports whether the control is valid. A control is considered valid if no validation errors exist with the current value. If the control is not present, null is returned.

invalid#

get invalid(): boolean|null
Reports whether the control is invalid, meaning that an error exists in the input value. If the control is not present, null is returned.

pending#

get pending(): boolean|null
Reports whether a control is pending, meaning that that async validation is occurring and errors are not yet available for the input value. If the control is not present, null is returned.

disabled#

get disabled(): boolean|null
Reports whether the control is disabled, meaning that the control is disabled in the UI and is exempt from validation checks and excluded from aggregate values of ancestor controls. If the control is not present, null is returned.

enabled#

get enabled(): boolean|null
Reports whether the control is enabled, meaning that the control is included in ancestor calculations of validity or value. If the control is not present, null is returned.

errors#

get errors(): ValidationErrors|null
Reports the control's validation errors. If the control is not present, null is returned.

pristine#

get pristine(): boolean|null
Reports whether the control is pristine, meaning that the user has not yet changed the value in the UI. If the control is not present, null is returned.

dirty#

get dirty(): boolean|null
Reports whether the control is dirty, meaning that the user has changed the value in the UI. If the control is not present, null is returned.

touched#

get touched(): boolean|null
Reports whether the control is touched, meaning that the user has triggered a `blur` event on it. If the control is not present, null is returned.

status#

get status(): string|null
Reports the validation status of the control. Possible values include: 'VALID', 'INVALID', 'DISABLED', and 'PENDING'. If the control is not present, null is returned.

untouched#

get untouched(): boolean|null
Reports whether the control is untouched, meaning that the user has not yet triggered a `blur` event on it. If the control is not present, null is returned.

statusChanges#

get statusChanges(): Observable<any>|null
Returns a multicasting observable that emits a validation status whenever it is calculated for the control. If the control is not present, null is returned.

valueChanges#

get valueChanges(): Observable<any>|null
Returns a multicasting observable of value changes for the control that emits every time the value of the control changes in the UI or programmatically. If the control is not present, null is returned.

path#

get path(): string[]|null
Returns an array that represents the path from the top-level form to this control. Each index is the string name of the control on that level.

reset#

reset(value: any = undefined): void
Resets the control with the provided value if the control is present.

hasError#

hasError(errorCode: string, path?: Array<string|number>|string): boolean
Reports whether the control with the given path has the error specified. For example, for the following `FormGroup`: ``` form = new FormGroup({ address: new FormGroup({ street: new FormControl() }) }); ``` The path to the 'street' control from the root form would be 'address' -> 'street'. It can be provided to this method in one of two formats: 1. An array of string control names, e.g. `['address', 'street']` 1. A period-delimited list of control names in one string, e.g. `'address.street'` If no path is given, this method checks for the error on the current control. Returns whether the given error is present in the control at the given path. If the control is not present, false is returned.

getError#

getError(errorCode: string, path?: Array<string|number>|string): any
Reports error data for the control with the given path. For example, for the following `FormGroup`: ``` form = new FormGroup({ address: new FormGroup({ street: new FormControl() }) }); ``` The path to the 'street' control from the root form would be 'address' -> 'street'. It can be provided to this method in one of two formats: 1. An array of string control names, e.g. `['address', 'street']` 1. A period-delimited list of control names in one string, e.g. `'address.street'` Returns error data for that particular error. If the control or error is not present, null is returned.