AbstractControlDirective

class

Base class for control directives.

See more...

abstract class AbstractControlDirective {
  abstract control: AbstractControl | null
  value: any
  valid: boolean | null
  invalid: boolean | null
  pending: boolean | null
  disabled: boolean | null
  enabled: boolean | null
  errors: ValidationErrors | null
  pristine: boolean | null
  dirty: boolean | null
  touched: boolean | null
  status: string | null
  untouched: boolean | null
  statusChanges: Observable<any> | null
  valueChanges: Observable<any> | null
  path: string[] | null
  reset(value: any = undefined): void
  hasError(errorCode: string, path?: string[]): boolean
  getError(errorCode: string, path?: string[]): any
}

Description

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

Properties

Property Description
abstract control: AbstractControl | null Read-only.

A reference to the underlying control.

value: any Read-only.

Reports the value of the control if it is present, otherwise null.

valid: boolean | null Read-only.

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: boolean | null Read-only.

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: boolean | null Read-only.

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: boolean | null Read-only.

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: boolean | null Read-only.

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: ValidationErrors | null Read-only.

Reports the control's validation errors. If the control is not present, null is returned.

pristine: boolean | null Read-only.

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: boolean | null Read-only.

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: boolean | null Read-only.

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: string | null Read-only.

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: boolean | null Read-only.

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: Observable<any> | null Read-only.

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: Observable<any> | null Read-only.

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: string[] | null Read-only.

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.

Methods

Resets the control with the provided value if the control is present.

reset(value: any = undefined): void

Parameters

value

Type: any.

Optional. Default is undefined.

Returns

void

Reports whether the control with the given path has the error specified. If no path is given, it checks for the error on the present control. If the control is not present, false is returned.

hasError(errorCode: string, path?: string[]): boolean

Parameters

errorCode

Type: string.

path

Type: string[].

Optional. Default is undefined.

Returns

boolean

Reports error data for the control with the given path. If the control is not present, null is returned.

getError(errorCode: string, path?: string[]): any

Parameters

errorCode

Type: string.

path

Type: string[].

Optional. Default is undefined.

Returns

any

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/forms/AbstractControlDirective