Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

errors

errors: object | null = null

Returns any errors generated by failing validation. If there are no errors, it will return null.

parent

parent: FormGroup | null = null

The parent control.

pristine

pristine: boolean = true

A control is marked pristine unless the user has triggered a change event on it.

status

status: ControlStatusEnum = ControlStatusEnum.VALID

The validation status of the control. There are four possible validation statuses:

  • VALID: control has passed all validation checks
  • INVALID: control has failed at least one validation check
  • DISABLED: control is exempt from validation checks

These statuses are mutually exclusive, so a control cannot be both valid AND invalid or invalid AND disabled.

touched

touched: boolean = false

A control is marked touched once the user has triggered a blur event on it.

validators

validators: IObservableArray<ValidatorFn<any>> | null

value

value: any

Accessors

dirty

dirty:

A control is marked pristine once the user has triggered a change event on it.

disabled

disabled:

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.

enabled

enabled:

A control is enabled as long as its status !== DISABLED.

In other words, it has a status of VALID, INVALID, or PENDING.

invalid

invalid:

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.

root

root:

Retrieves the top-level ancestor of this control.

untouched

untouched:

A control is untouched if the user has not yet triggered a blur event on it.

valid

valid:

A control is valid when its status === VALID.

In order to have this status, the control must have passed all its validation checks.

Methods

Protected Abstract _allControlsDisabled

  • _allControlsDisabled(): boolean

Protected Abstract _anyControls

  • _anyControls(condition: function): boolean

_anyControlsDirty

  • _anyControlsDirty(): boolean

Private _anyControlsHaveStatus

  • _anyControlsHaveStatus(status: string): boolean
  • Parameters

    • status: string

    Returns boolean

_anyControlsTouched

  • _anyControlsTouched(): boolean

Private _calculateStatus

Protected Abstract _forEachChild

  • _forEachChild(cb: function): void
  • internal

    Parameters

    • cb: function
        • (v: any, k: string): void
        • Parameters

          • v: any
          • k: string

          Returns void

    Returns void

Private _runValidator

  • _runValidator(): object | null

Private _setInitialStatus

  • _setInitialStatus(): void

Private _updateAncestors

  • _updateAncestors(onlySelf?: boolean): void
  • Parameters

    • Default value onlySelf: boolean = false

    Returns void

_updatePristine

  • _updatePristine(opts?: object): void
  • internal

    Parameters

    • Default value opts: object = {}
      • Optional onlySelf?: boolean

    Returns void

_updateStatus

  • _updateStatus(onlySelf?: boolean): void
  • internal

    Parameters

    • Optional onlySelf: boolean

    Returns void

_updateTouched

  • _updateTouched(onlySelf?: boolean): void
  • internal

    Parameters

    • Optional onlySelf: boolean

    Returns void

Protected Abstract _updateValue

  • _updateValue(): void

clearValidators

disable

  • disable(onlySelf?: boolean): 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.

    If the control has children, all children will be disabled to maintain the model.

    Parameters

    • Default value onlySelf: boolean = false

    Returns void

enable

  • enable(onlySelf?: boolean): 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.

    If the control has children, all children will be enabled.

    Parameters

    • Default value onlySelf: boolean = false

    Returns void

get

  • 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']);

    Parameters

    • path: Array<string | number> | string

    Returns AbstractControl | null

getError

  • getError(errorCode: string, path?: Array<string | number> | string): any
  • 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.

    Parameters

    • errorCode: string
    • Optional path: Array<string | number> | string

    Returns any

hasError

  • hasError(errorCode: string, path?: Array<string | number> | string): boolean
  • 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.

    Parameters

    • errorCode: string
    • Optional path: Array<string | number> | string

    Returns boolean

markAsDirty

  • markAsDirty(onlySelf?: boolean): void
  • 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.

    Parameters

    • Optional onlySelf: boolean

    Returns void

markAsPristine

  • markAsPristine(onlySelf?: boolean): void
  • Marks the control as touched.

    This will also mark all direct ancestors as touched to maintain the model.

    Parameters

    • Optional onlySelf: boolean

    Returns void

markAsTouched

  • markAsTouched(onlySelf?: boolean): void
  • Marks the control as touched.

    This will also mark all direct ancestors as touched to maintain the model.

    Parameters

    • Optional onlySelf: boolean

    Returns void

markAsUntouched

  • markAsUntouched(onlySelf?: boolean): void
  • 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.

    Parameters

    • Optional onlySelf: boolean

    Returns void

Abstract patchValue

  • patchValue(value: any, onlySelf?: boolean): void
  • Patches the value of the control. Abstract method (implemented in sub-classes).

    Parameters

    • value: any
    • Optional onlySelf: boolean

    Returns void

removeError

  • Remove errors on a form control.

    This is used when validations are run manually by the user, rather than automatically.

    Parameters

    Returns void

setError

  • Sets errors on a form control.

    This is used when validations are run manually by the user, rather than automatically.

    Parameters

    Returns void

setParent

setValidators

Abstract setValue

  • setValue(value: any, onlySelf?: boolean): void
  • Sets the value of the control. Abstract method (implemented in sub-classes).

    Parameters

    • value: any
    • Optional onlySelf: boolean

    Returns void

shouldShowError

  • shouldShowError(errorCode: string, path?: Array<string | number> | string): boolean
  • Parameters

    • errorCode: string
    • Optional path: Array<string | number> | string

    Returns boolean

updateValueAndValidity

  • updateValueAndValidity(onlySelf?: boolean): void
  • Re-calculates the value and validation status of the control.

    By default, it will also update the value and validity of its ancestors.

    Parameters

    • Default value onlySelf: boolean = false

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc