Skip to main content

Class: DisabledControl

Hierarchy​

  • FormControl

    ↳ DisabledControl

Constructors​

constructor​

• new DisabledControl()

Overrides​

FormControl.constructor

Defined in​

libs/ng-core/src/lib/models/disabled-control.ts:4

Properties​

errors​

• Readonly errors: null | ValidationErrors

An object containing any errors generated by failing validation, or null if there are no errors.

Inherited from​

FormControl.errors

Defined in​

node_modules/@angular/forms/forms.d.ts:146


pristine​

• Readonly pristine: boolean

A control is pristine if the user has not yet changed the value in the UI.

returns True if the user has not yet changed the value in the UI; compare dirty. Programmatic changes to a control's value do not mark it dirty.

Inherited from​

FormControl.pristine

Defined in​

node_modules/@angular/forms/forms.d.ts:154


status​

• Readonly status: string

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

  • VALID: This control has passed all validation checks.
  • INVALID: This control has failed at least one validation check.
  • PENDING: This control is in the midst of conducting a validation check.
  • DISABLED: This control is exempt from validation checks.

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

Inherited from​

FormControl.status

Defined in​

node_modules/@angular/forms/forms.d.ts:92


statusChanges​

• Readonly statusChanges: Observable<any>

A multicasting observable that emits an event every time the validation status of the control recalculates.

see {@link AbstractControl.status}

Inherited from​

FormControl.statusChanges

Defined in​

node_modules/@angular/forms/forms.d.ts:190


touched​

• Readonly touched: boolean

True if the control is marked as touched.

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

Inherited from​

FormControl.touched

Defined in​

node_modules/@angular/forms/forms.d.ts:169


value​

• Readonly value: any

The current value of the control.

  • For a FormControl, the current value.
  • For an enabled FormGroup, the values of enabled controls as an object with a key-value pair for each member of the group.
  • For a disabled FormGroup, the values of all controls as an object with a key-value pair for each member of the group.
  • For a FormArray, the values of enabled controls as an array.

Inherited from​

FormControl.value

Defined in​

node_modules/@angular/forms/forms.d.ts:52


valueChanges​

• Readonly valueChanges: Observable<any>

A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically. It also emits an event each time you call enable() or disable() without passing along {emitEvent: false} as a function argument.

Inherited from​

FormControl.valueChanges

Defined in​

node_modules/@angular/forms/forms.d.ts:182

Accessors​

asyncValidator​

• get asyncValidator(): null | AsyncValidatorFn

Returns the function that is used to determine the validity of this control asynchronously. If multiple validators have been added, this will be a single composed function. See Validators.compose() for additional information.

Returns​

null | AsyncValidatorFn

Inherited from​

FormControl.asyncValidator

Defined in​

node_modules/@angular/forms/forms.d.ts:74

• set asyncValidator(asyncValidatorFn): void

Returns the function that is used to determine the validity of this control asynchronously. If multiple validators have been added, this will be a single composed function. See Validators.compose() for additional information.

Parameters​

NameType
asyncValidatorFnnull | AsyncValidatorFn

Returns​

void

Inherited from​

FormControl.asyncValidator

Defined in​

node_modules/@angular/forms/forms.d.ts:75


dirty​

• get dirty(): boolean

A control is dirty if the user has changed the value in the UI.

Returns​

boolean

True if the user has changed the value of this control in the UI; compare pristine. Programmatic changes to a control's value do not mark it dirty.

Inherited from​

FormControl.dirty

Defined in​

node_modules/@angular/forms/forms.d.ts:162


disabled​

• get disabled(): boolean

A control is disabled when its status is DISABLED.

Disabled controls are exempt from validation checks and are not included in the aggregate value of their ancestor controls.

see {@link AbstractControl.status}

Returns​

boolean

True if the control is disabled, false otherwise.

Inherited from​

FormControl.disabled

Defined in​

node_modules/@angular/forms/forms.d.ts:131


enabled​

• get enabled(): boolean

A control is enabled as long as its status is not DISABLED.

see {@link AbstractControl.status}

Returns​

boolean

True if the control has any status other than 'DISABLED', false if the status is 'DISABLED'.

Inherited from​

FormControl.enabled

Defined in​

node_modules/@angular/forms/forms.d.ts:141


invalid​

• get invalid(): boolean

A control is invalid when its status is INVALID.

see {@link AbstractControl.status}

Returns​

boolean

True if this control has failed one or more of its validation checks, false otherwise.

Inherited from​

FormControl.invalid

Defined in​

node_modules/@angular/forms/forms.d.ts:110


parent​

• get parent(): null | FormGroup | FormArray

The parent control.

Returns​

null | FormGroup | FormArray

Inherited from​

FormControl.parent

Defined in​

node_modules/@angular/forms/forms.d.ts:79


pending​

• get pending(): boolean

A control is pending when its status is PENDING.

see {@link AbstractControl.status}

Returns​

boolean

True if this control is in the process of conducting a validation check, false otherwise.

Inherited from​

FormControl.pending

Defined in​

node_modules/@angular/forms/forms.d.ts:119


root​

• get root(): AbstractControl

Retrieves the top-level ancestor of this control.

Returns​

AbstractControl

Inherited from​

FormControl.root

Defined in​

node_modules/@angular/forms/forms.d.ts:595


untouched​

• get untouched(): boolean

True if the control has not been marked as touched

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

Returns​

boolean

Inherited from​

FormControl.untouched

Defined in​

node_modules/@angular/forms/forms.d.ts:176


updateOn​

• get updateOn(): FormHooks

Reports the update strategy of the AbstractControl (meaning the event on which the control updates itself). Possible values: 'change' | 'blur' | 'submit' Default value: 'change'

Returns​

FormHooks

Inherited from​

FormControl.updateOn

Defined in​

node_modules/@angular/forms/forms.d.ts:197


valid​

• get valid(): boolean

A control is valid when its status is VALID.

see {@link AbstractControl.status}

Returns​

boolean

True if the control has passed all of its validation tests, false otherwise.

Inherited from​

FormControl.valid

Defined in​

node_modules/@angular/forms/forms.d.ts:101


validator​

• get validator(): null | ValidatorFn

Returns the function that is used to determine the validity of this control synchronously. If multiple validators have been added, this will be a single composed function. See Validators.compose() for additional information.

Returns​

null | ValidatorFn

Inherited from​

FormControl.validator

Defined in​

node_modules/@angular/forms/forms.d.ts:67

• set validator(validatorFn): void

Returns the function that is used to determine the validity of this control synchronously. If multiple validators have been added, this will be a single composed function. See Validators.compose() for additional information.

Parameters​

NameType
validatorFnnull | ValidatorFn

Returns​

void

Inherited from​

FormControl.validator

Defined in​

node_modules/@angular/forms/forms.d.ts:68

Methods​

addAsyncValidators​

â–¸ addAsyncValidators(validators): void

Add an asynchronous validator or validators to this control, without affecting other validators.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Adding a validator that already exists will have no effect.

Parameters​

NameTypeDescription
validatorsAsyncValidatorFn | AsyncValidatorFn[]The new asynchronous validator function or functions to add to this control.

Returns​

void

Inherited from​

FormControl.addAsyncValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:244


addValidators​

â–¸ addValidators(validators): void

Add a synchronous validator or validators to this control, without affecting other validators.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Adding a validator that already exists will have no effect. If duplicate validator functions are present in the validators array, only the first instance would be added to a form control.

Parameters​

NameTypeDescription
validatorsValidatorFn | ValidatorFn[]The new validator function or functions to add to this control.

Returns​

void

Inherited from​

FormControl.addValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:232


clearAsyncValidators​

â–¸ clearAsyncValidators(): void

Empties out the async validator list.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Returns​

void

Inherited from​

FormControl.clearAsyncValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:301


clearValidators​

â–¸ clearValidators(): void

Empties out the synchronous validator list.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Returns​

void

Inherited from​

FormControl.clearValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:293


disable​

â–¸ disable(opts?): void

Disables the control. This means the control is exempt from validation checks and excluded from the aggregate value of any parent. Its status is DISABLED.

If the control has children, all children are also disabled.

see {@link AbstractControl.status}

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control propagates changes and emits events after the control is disabled. onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false. emitEvent: When true or not supplied (the default), both the statusChanges and valueChanges observables emit events with the latest status and value when the control is disabled. When false, no events are emitted.
opts.emitEvent?boolean-
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.disable

Defined in​

node_modules/@angular/forms/forms.d.ts:413


enable​

â–¸ enable(): void

Returns​

void

Overrides​

FormControl.enable

Defined in​

libs/ng-core/src/lib/models/disabled-control.ts:9


get​

â–¸ get(path): null | AbstractControl

Retrieves a child control given the control's name or path.

usagenotes

Retrieve a nested control​

For example, to get a name control nested within a person sub-group:

  • this.form.get('person.name');

-OR-

  • this.form.get(['person', 'name']);

Retrieve a control in a FormArray​

When accessing an element inside a FormArray, you can use an element index. For example, to get a price control from the first element in an items array you can use:

  • this.form.get('items.0.price');

-OR-

  • this.form.get(['items', 0, 'price']);

Parameters​

NameTypeDescription
pathstring | (string | number)[]A dot-delimited string or array of string/number values that define the path to the control.

Returns​

null | AbstractControl

Inherited from​

FormControl.get

Defined in​

node_modules/@angular/forms/forms.d.ts:532


getError​

â–¸ getError(errorCode, path?): any

description Reports error data for the control with the given path.

usagenotes 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']
  2. A period-delimited list of control names in one string, e.g. 'address.street'

Parameters​

NameTypeDescription
errorCodestringThe code of the error to check
path?string | (string | number)[]A list of control names that designates how to move from the current control to the control that should be queried for errors.

Returns​

any

error data for that particular error. If the control or error is not present, null is returned.

Inherited from​

FormControl.getError

Defined in​

node_modules/@angular/forms/forms.d.ts:560


hasAsyncValidator​

â–¸ hasAsyncValidator(validator): boolean

Check whether an asynchronous validator function is present on this control. The provided validator must be a reference to the exact same function that was provided.

Parameters​

NameTypeDescription
validatorAsyncValidatorFnThe asynchronous validator to check for presence. Compared by function reference.

Returns​

boolean

Whether the provided asynchronous validator was found on this control.

Inherited from​

FormControl.hasAsyncValidator

Defined in​

node_modules/@angular/forms/forms.d.ts:285


hasError​

â–¸ hasError(errorCode, path?): boolean

description Reports whether the control with the given path has the error specified.

usagenotes 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']
  2. 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.

Parameters​

NameTypeDescription
errorCodestringThe code of the error to check
path?string | (string | number)[]A list of control names that designates how to move from the current control to the control that should be queried for errors.

Returns​

boolean

whether the given error is present in the control at the given path.

If the control is not present, false is returned.

Inherited from​

FormControl.hasError

Defined in​

node_modules/@angular/forms/forms.d.ts:591


hasValidator​

â–¸ hasValidator(validator): boolean

Check whether a synchronous validator function is present on this control. The provided validator must be a reference to the exact same function that was provided.

Parameters​

NameTypeDescription
validatorValidatorFnThe validator to check for presence. Compared by function reference.

Returns​

boolean

Whether the provided validator was found on this control.

Inherited from​

FormControl.hasValidator

Defined in​

node_modules/@angular/forms/forms.d.ts:276


markAllAsTouched​

â–¸ markAllAsTouched(): void

Marks the control and all its descendant controls as touched.

see markAsTouched()

Returns​

void

Inherited from​

FormControl.markAllAsTouched

Defined in​

node_modules/@angular/forms/forms.d.ts:322


markAsDirty​

â–¸ markAsDirty(opts?): void

Marks the control as dirty. A control becomes dirty when the control's value is changed through the UI; compare markAsTouched.

see markAsTouched()

see markAsUntouched()

see markAsPristine()

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control propagates changes and emits events after marking is applied. * onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false.
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.markAsDirty

Defined in​

node_modules/@angular/forms/forms.d.ts:354


markAsPending​

â–¸ markAsPending(opts?): void

Marks the control as pending.

A control is pending while the control performs async validation.

see {@link AbstractControl.status}

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control propagates changes and emits events after marking is applied. onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false. emitEvent: When true or not supplied (the default), the statusChanges observable emits an event with the latest status the control is marked pending. When false, no events are emitted.
opts.emitEvent?boolean-
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.markAsPending

Defined in​

node_modules/@angular/forms/forms.d.ts:392


markAsPristine​

â–¸ markAsPristine(opts?): void

Marks the control as pristine.

If the control has any children, marks all children as pristine, and recalculates the pristine status of all parent controls.

see markAsTouched()

see markAsUntouched()

see markAsDirty()

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control emits events after marking is applied. * onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false.
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.markAsPristine

Defined in​

node_modules/@angular/forms/forms.d.ts:373


markAsTouched​

â–¸ markAsTouched(opts?): void

Marks the control as touched. A control is touched by focus and blur events that do not change the value.

see markAsUntouched()

see markAsDirty()

see markAsPristine()

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control propagates changes and emits events after marking is applied. * onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false.
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.markAsTouched

Defined in​

node_modules/@angular/forms/forms.d.ts:315


markAsUntouched​

â–¸ markAsUntouched(opts?): void

Marks the control as untouched.

If the control has any children, also marks all children as untouched and recalculates the touched status of all parent controls.

see markAsTouched()

see markAsDirty()

see markAsPristine()

Parameters​

NameTypeDescription
opts?ObjectConfiguration options that determine how the control propagates changes and emits events after the marking is applied. * onlySelf: When true, mark only this control. When false or not supplied, marks all direct ancestors. Default is false.
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.markAsUntouched

Defined in​

node_modules/@angular/forms/forms.d.ts:338


patchValue​

â–¸ patchValue(value, options?): void

Patches the value of a control.

This function is functionally the same as {@link FormControl#setValue setValue} at this level. It exists for symmetry with {@link FormGroup#patchValue patchValue} on FormGroups and FormArrays, where it does behave differently.

see setValue for options

Parameters​

NameType
valueany
options?Object
options.emitEvent?boolean
options.emitModelToViewChange?boolean
options.emitViewToModelChange?boolean
options.onlySelf?boolean

Returns​

void

Inherited from​

FormControl.patchValue

Defined in​

node_modules/@angular/forms/forms.d.ts:1938


registerOnChange​

â–¸ registerOnChange(fn): void

Register a listener for change events.

Parameters​

NameTypeDescription
fnFunctionThe method that is called when the value changes

Returns​

void

Inherited from​

FormControl.registerOnChange

Defined in​

node_modules/@angular/forms/forms.d.ts:1971


registerOnDisabledChange​

â–¸ registerOnDisabledChange(fn): void

Register a listener for disabled events.

Parameters​

NameTypeDescription
fn(isDisabled: boolean) => voidThe method that is called when the disabled status changes.

Returns​

void

Inherited from​

FormControl.registerOnDisabledChange

Defined in​

node_modules/@angular/forms/forms.d.ts:1977


removeAsyncValidators​

â–¸ removeAsyncValidators(validators): void

Remove an asynchronous validator from this control, without affecting other validators. Validators are compared by function reference; you must pass a reference to the exact same validator function as the one that was originally set. If a provided validator is not found, it is ignored.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Parameters​

NameTypeDescription
validatorsAsyncValidatorFn | AsyncValidatorFn[]The asynchronous validator or validators to remove.

Returns​

void

Inherited from​

FormControl.removeAsyncValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:268


removeValidators​

â–¸ removeValidators(validators): void

Remove a synchronous validator from this control, without affecting other validators. Validators are compared by function reference; you must pass a reference to the exact same validator function as the one that was originally set. If a provided validator is not found, it is ignored.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

Parameters​

NameTypeDescription
validatorsValidatorFn | ValidatorFn[]The validator or validators to remove.

Returns​

void

Inherited from​

FormControl.removeValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:256


reset​

â–¸ reset(formState?, options?): void

Resets the form control, marking it pristine and untouched, and setting the value to null.

Parameters​

NameTypeDescription
formState?anyResets the control with an initial value, or an object that defines the initial value and disabled state.
options?ObjectConfiguration options that determine how the control propagates changes and emits events after the value changes. onlySelf: When true, each change only affects this control, and not its parent. Default is false. emitEvent: When true or not supplied (the default), both the statusChanges and valueChanges observables emit events with the latest status and value when the control is reset. When false, no events are emitted.
options.emitEvent?boolean-
options.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.reset

Defined in​

node_modules/@angular/forms/forms.d.ts:1962


setAsyncValidators​

â–¸ setAsyncValidators(validators): void

Sets the asynchronous validators that are active on this control. Calling this overwrites any existing asynchronous validators.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

If you want to add a new validator without affecting existing ones, consider using addAsyncValidators() method instead.

Parameters​

NameType
validatorsnull | AsyncValidatorFn | AsyncValidatorFn[]

Returns​

void

Inherited from​

FormControl.setAsyncValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:219


setErrors​

â–¸ setErrors(errors, opts?): void

Sets errors on a form control when running validations manually, rather than automatically.

Calling setErrors also updates the validity of the parent control.

usagenotes

Manually set the errors for a control​

const login = new FormControl('someLogin');
login.setErrors({
notUnique: true
});

expect(login.valid).toEqual(false);
expect(login.errors).toEqual({ notUnique: true });

login.setValue('someOtherLogin');

expect(login.valid).toEqual(true);

Parameters​

NameType
errorsnull | ValidationErrors
opts?Object
opts.emitEvent?boolean

Returns​

void

Inherited from​

FormControl.setErrors

Defined in​

node_modules/@angular/forms/forms.d.ts:501


setParent​

â–¸ setParent(parent): void

Parameters​

NameTypeDescription
parentFormGroup | FormArraySets the parent of the control

Returns​

void

Inherited from​

FormControl.setParent

Defined in​

node_modules/@angular/forms/forms.d.ts:443


setValidators​

â–¸ setValidators(validators): void

Sets the synchronous validators that are active on this control. Calling this overwrites any existing synchronous validators.

When you add or remove a validator at run time, you must call updateValueAndValidity() for the new validation to take effect.

If you want to add a new validator without affecting existing ones, consider using addValidators() method instead.

Parameters​

NameType
validatorsnull | ValidatorFn | ValidatorFn[]

Returns​

void

Inherited from​

FormControl.setValidators

Defined in​

node_modules/@angular/forms/forms.d.ts:208


setValue​

â–¸ setValue(value, options?): void

Sets a new value for the form control.

Parameters​

NameTypeDescription
valueanyThe new value for the control.
options?ObjectConfiguration options that determine how the control propagates changes and emits events when the value changes. The configuration options are passed to the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method. onlySelf: When true, each change only affects this control, and not its parent. Default is false. emitEvent: When true or not supplied (the default), both the statusChanges and valueChanges observables emit events with the latest status and value when the control value is updated. When false, no events are emitted. emitModelToViewChange: When true or not supplied (the default), each change triggers an onChange event to update the view. emitViewToModelChange: When true or not supplied (the default), each change triggers an ngModelChange event to update the model.
options.emitEvent?boolean-
options.emitModelToViewChange?boolean-
options.emitViewToModelChange?boolean-
options.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.setValue

Defined in​

node_modules/@angular/forms/forms.d.ts:1923


updateValueAndValidity​

â–¸ updateValueAndValidity(opts?): void

Recalculates the value and validation status of the control.

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

Parameters​

NameTypeDescription
opts?ObjectConfiguration options determine how the control propagates changes and emits events after updates and validity checks are applied. onlySelf: When true, only update this control. When false or not supplied, update all direct ancestors. Default is false. emitEvent: When true or not supplied (the default), both the statusChanges and valueChanges observables emit events with the latest status and value when the control is updated. When false, no events are emitted.
opts.emitEvent?boolean-
opts.onlySelf?boolean-

Returns​

void

Inherited from​

FormControl.updateValueAndValidity

Defined in​

node_modules/@angular/forms/forms.d.ts:470