AbstractControl

AbstractControl

Stable Class

What it does

This is the base class for FormControl, FormGroup, and FormArray.

It provides some of the shared behavior that all controls and groups of controls have, like running validators, calculating status, and resetting state. It also defines the properties that are shared between all sub-classes, like value, valid, and dirty. It shouldn't be instantiated directly.

Class Overview

class AbstractControl {
  constructor(validator: ValidatorFn, asyncValidator: AsyncValidatorFn)
  
  
  validator : ValidatorFn
  asyncValidator : AsyncValidatorFn
  value : any
  parent : FormGroup|FormArray
  status : string
  valid : boolean
  invalid : boolean
  pending : boolean
  disabled : boolean
  enabled : boolean
  errors : ValidationErrors|
}

Class Description

Constructor

constructor(validator: ValidatorFn, asyncValidator: AsyncValidatorFn)

Class Details

validator : ValidatorFn
asyncValidator : AsyncValidatorFn
value : any

The value of the control.

parent : FormGroup|FormArray

The parent control.

status : string

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
  • PENDING: control is in the midst of conducting a 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.

valid : boolean

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

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

invalid : boolean

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.

pending : boolean

A control is pending when its status === PENDING.

In order to have this status, the control must be in the middle of conducting a validation check.

disabled : boolean

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 : boolean

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

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

errors : ValidationErrors|

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

exported from forms-index, defined in forms/src/model.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/forms/index/AbstractControl-class.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部