@rxap/forms
Version:
This package provides a set of tools and directives to simplify working with Angular forms, including reactive forms, custom validators, and form directives for handling loading, submitting, and error states. It offers decorators for defining forms and co
1,688 lines (932 loc) • 34 kB
Markdown
[**@rxap/forms v19.1.0**](../README.md)
***
[@rxap/forms](../globals.md) / AbstractControl
Interface: AbstractControl\<T\>
Defined in: [packages/angular/forms/src/lib/types.ts:70](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L70)
# Extends
- `AbstractControl`
# Type Parameters
• **T** = `any`
# Properties
## controlId?
`optional` **controlId**: `string`
Defined in: [packages/angular/forms/src/lib/types.ts:72](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L72)
***
## errors
`readonly` **errors**: `null` \| `ValidationErrors`
Defined in: node\_modules/@angular/forms/index.d.ts:2231
An object containing any errors generated by failing validation,
or null if there are no errors.
### Inherited from
`NgAbstractControl.errors`
***
## events
`readonly` **events**: `Observable`\<`ControlEvent`\<`any`\>\>
Defined in: node\_modules/@angular/forms/index.d.ts:2278
A multicasting observable that emits an event every time the state of the control changes.
It emits for value, status, pristine or touched changes.
**Note**: On value change, the emit happens right after a value of this control is updated. The
value of a parent control (for example if this FormControl is a part of a FormGroup) is updated
later, so accessing a value of a parent control (using the `value` property) from the callback
of this event might result in getting a value that has not been updated yet. Subscribe to the
`events` of the parent control instead.
For other event types, the events are emitted after the parent control has been updated.
### Inherited from
`NgAbstractControl.events`
***
## fullControlPath?
`optional` **fullControlPath**: `string`
Defined in: [packages/angular/forms/src/lib/types.ts:73](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L73)
***
## readonly?
`optional` **readonly**: `boolean`
Defined in: [packages/angular/forms/src/lib/types.ts:75](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L75)
***
## rxapFormDefinition?
`optional` **rxapFormDefinition**: [`FormDefinition`](FormDefinition.md)\<`any`, `any`, `any`\>
Defined in: [packages/angular/forms/src/lib/types.ts:74](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L74)
***
## stateChanges?
`optional` **stateChanges**: `Subject`\<`any`\>
Defined in: [packages/angular/forms/src/lib/types.ts:76](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L76)
***
## statusChanges
`readonly` **statusChanges**: `Observable`\<`FormControlStatus`\>
Defined in: node\_modules/@angular/forms/index.d.ts:2298
A multicasting observable that emits an event every time the validation `status` of the control
recalculates.
### See
- FormControlStatus
- [AbstractControl.status](AbstractControl.md#status)
### Inherited from
`NgAbstractControl.statusChanges`
***
## value
**value**: `T`
Defined in: [packages/angular/forms/src/lib/types.ts:71](https://gitlab.com/rxap/packages/-/blob/36b0e9732b24717840935712e316593ff6aba795/packages/angular/forms/src/lib/types.ts#L71)
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.
### Overrides
`NgAbstractControl.value`
***
## valueChanges
`readonly` **valueChanges**: `Observable`\<`any`\>
Defined in: node\_modules/@angular/forms/index.d.ts:2290
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.
**Note**: the emit happens right after a value of this control is updated. The value of a
parent control (for example if this FormControl is a part of a FormGroup) is updated later, so
accessing a value of a parent control (using the `value` property) from the callback of this
event might result in getting a value that has not been updated yet. Subscribe to the
`valueChanges` event of the parent control instead.
### Inherited from
`NgAbstractControl.valueChanges`
# Accessors
## asyncValidator
### Get Signature
**get** **asyncValidator**(): `null` \| `AsyncValidatorFn`
Defined in: node\_modules/@angular/forms/index.d.ts:2161
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`
### Set Signature
**set** **asyncValidator**(`asyncValidatorFn`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2162
#### Parameters
##### asyncValidatorFn
`null` | `AsyncValidatorFn`
#### Returns
`void`
### Inherited from
`NgAbstractControl.asyncValidator`
***
## dirty
### Get Signature
**get** **dirty**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2249
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
`NgAbstractControl.dirty`
***
## disabled
### Get Signature
**get** **disabled**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2216
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
[AbstractControl.status](AbstractControl.md#status)
#### Returns
`boolean`
True if the control is disabled, false otherwise.
### Inherited from
`NgAbstractControl.disabled`
***
## enabled
### Get Signature
**get** **enabled**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2226
A control is `enabled` as long as its `status` is not `DISABLED`.
#### See
[AbstractControl.status](AbstractControl.md#status)
#### Returns
`boolean`
True if the control has any status other than 'DISABLED',
false if the status is 'DISABLED'.
### Inherited from
`NgAbstractControl.enabled`
***
## invalid
### Get Signature
**get** **invalid**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2195
A control is `invalid` when its `status` is `INVALID`.
#### See
[AbstractControl.status](AbstractControl.md#status)
#### Returns
`boolean`
True if this control has failed one or more of its validation checks,
false otherwise.
### Inherited from
`NgAbstractControl.invalid`
***
## parent
### Get Signature
**get** **parent**(): `null` \| `FormGroup`\<`any`\> \| `FormArray`\<`any`\>
Defined in: node\_modules/@angular/forms/index.d.ts:2166
The parent control.
#### Returns
`null` \| `FormGroup`\<`any`\> \| `FormArray`\<`any`\>
### Inherited from
`NgAbstractControl.parent`
***
## pending
### Get Signature
**get** **pending**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2204
A control is `pending` when its `status` is `PENDING`.
#### See
[AbstractControl.status](AbstractControl.md#status)
#### Returns
`boolean`
True if this control is in the process of conducting a validation check,
false otherwise.
### Inherited from
`NgAbstractControl.pending`
***
## pristine
### Get Signature
**get** **pristine**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2239
A control is `pristine` if the user has not yet changed
the value in the UI.
#### Returns
`boolean`
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.
### Set Signature
**set** **pristine**(`value`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2240
#### Parameters
##### value
`boolean`
#### Returns
`void`
### Inherited from
`NgAbstractControl.pristine`
***
## root
### Get Signature
**get** **root**(): `AbstractControl`
Defined in: node\_modules/@angular/forms/index.d.ts:2758
Retrieves the top-level ancestor of this control.
#### Returns
`AbstractControl`
### Inherited from
`NgAbstractControl.root`
***
## status
### Get Signature
**get** **status**(): `FormControlStatus`
Defined in: node\_modules/@angular/forms/index.d.ts:2175
The validation status of the control.
#### See
FormControlStatus
These status values are mutually exclusive, so a control cannot be
both valid AND invalid or invalid AND disabled.
#### Returns
`FormControlStatus`
### Set Signature
**set** **status**(`value`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2176
#### Parameters
##### value
`FormControlStatus`
#### Returns
`void`
### Inherited from
`NgAbstractControl.status`
***
## touched
### Get Signature
**get** **touched**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2256
True if the control is marked as `touched`.
A control is marked `touched` once the user has triggered
a `blur` event on it.
#### Returns
`boolean`
### Set Signature
**set** **touched**(`value`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2257
#### Parameters
##### value
`boolean`
#### Returns
`void`
### Inherited from
`NgAbstractControl.touched`
***
## untouched
### Get Signature
**get** **untouched**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2265
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
`NgAbstractControl.untouched`
***
## updateOn
### Get Signature
**get** **updateOn**(): `FormHooks`
Defined in: node\_modules/@angular/forms/index.d.ts:2305
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
`NgAbstractControl.updateOn`
***
## valid
### Get Signature
**get** **valid**(): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2186
A control is `valid` when its `status` is `VALID`.
#### See
[AbstractControl.status](AbstractControl.md#status)
#### Returns
`boolean`
True if the control has passed all of its validation tests,
false otherwise.
### Inherited from
`NgAbstractControl.valid`
***
## validator
### Get Signature
**get** **validator**(): `null` \| `ValidatorFn`
Defined in: node\_modules/@angular/forms/index.d.ts:2154
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`
### Set Signature
**set** **validator**(`validatorFn`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2155
#### Parameters
##### validatorFn
`null` | `ValidatorFn`
#### Returns
`void`
### Inherited from
`NgAbstractControl.validator`
# Methods
## addAsyncValidators()
**addAsyncValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2352
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
#### validators
The new asynchronous validator function or functions to add to this control.
`AsyncValidatorFn` | `AsyncValidatorFn`[]
### Returns
`void`
### Inherited from
`NgAbstractControl.addAsyncValidators`
***
## addValidators()
**addValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2340
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
#### validators
The new validator function or functions to add to this control.
`ValidatorFn` | `ValidatorFn`[]
### Returns
`void`
### Inherited from
`NgAbstractControl.addValidators`
***
## clearAsyncValidators()
**clearAsyncValidators**(): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2443
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
`NgAbstractControl.clearAsyncValidators`
***
## clearValidators()
**clearValidators**(): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2435
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
`NgAbstractControl.clearValidators`
***
## disable()
**disable**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2580
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.
### Parameters
#### opts?
Configuration 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), the `statusChanges`,
`valueChanges` and `events`
observables emit events with the latest status and value when the control is disabled.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
[AbstractControl.status](AbstractControl.md#status)
### Inherited from
`NgAbstractControl.disable`
***
## enable()
**enable**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2602
Enables the control. This means the control is included in validation checks and
the aggregate value of its parent. Its status recalculates based on its value and
its validators.
By default, if the control has children, all children are enabled.
### Parameters
#### opts?
Configure options that control how the control propagates changes and
emits events when marked as untouched
* `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`,
`valueChanges` and `events`
observables emit events with the latest status and value when the control is enabled.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
[AbstractControl.status](AbstractControl.md#status)
### Inherited from
`NgAbstractControl.enable`
***
## get()
### Call Signature
**get**\<`P`\>(`path`): `null` \| `AbstractControl`\<`ɵGetProperty`\<`any`, `P`\>, `ɵGetProperty`\<`any`, `P`\>\>
Defined in: node\_modules/@angular/forms/index.d.ts:2688
Retrieves a child control given the control's name or path.
This signature for get supports strings and `const` arrays (`.get(['foo', 'bar'] as const)`).
#### Type Parameters
• **P** *extends* `string` \| readonly (`string` \| `number`)[]
#### Parameters
##### path
`P`
#### Returns
`null` \| `AbstractControl`\<`ɵGetProperty`\<`any`, `P`\>, `ɵGetProperty`\<`any`, `P`\>\>
#### Inherited from
`NgAbstractControl.get`
### Call Signature
**get**\<`P`\>(`path`): `null` \| `AbstractControl`\<`ɵGetProperty`\<`any`, `P`\>, `ɵGetProperty`\<`any`, `P`\>\>
Defined in: node\_modules/@angular/forms/index.d.ts:2695
Retrieves a child control given the control's name or path.
This signature for `get` supports non-const (mutable) arrays. Inferred type
information will not be as robust, so prefer to pass a `readonly` array if possible.
#### Type Parameters
• **P** *extends* `string` \| (`string` \| `number`)[]
#### Parameters
##### path
`P`
#### Returns
`null` \| `AbstractControl`\<`ɵGetProperty`\<`any`, `P`\>, `ɵGetProperty`\<`any`, `P`\>\>
#### Inherited from
`NgAbstractControl.get`
***
## getError()
**getError**(`errorCode`, `path`?): `any`
Defined in: node\_modules/@angular/forms/index.d.ts:2723
### Parameters
#### errorCode
`string`
The code of the error to check
#### path?
A list of control names that designates how to move from the current control
to the control that should be queried for errors.
`string` | (`string` \| `number`)[]
### Returns
`any`
error data for that particular error. If the control or error is not present,
null is returned.
### Description
Reports error data for the control with the given path.
### Usage Notes
For example, for the following `FormGroup`:
```ts
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'`
### Inherited from
`NgAbstractControl.getError`
***
## getRawValue()
**getRawValue**(): `any`
Defined in: node\_modules/@angular/forms/index.d.ts:2629
The raw value of this control. For most control implementations, the raw value will include
disabled children.
### Returns
`any`
### Inherited from
`NgAbstractControl.getRawValue`
***
## hasAsyncValidator()
**hasAsyncValidator**(`validator`): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2427
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
#### validator
`AsyncValidatorFn`
The asynchronous validator to check for presence. Compared by function
reference.
### Returns
`boolean`
Whether the provided asynchronous validator was found on this control.
### Inherited from
`NgAbstractControl.hasAsyncValidator`
***
## hasError()
**hasError**(`errorCode`, `path`?): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2754
### Parameters
#### errorCode
`string`
The code of the error to check
#### path?
A list of control names that designates how to move from the current control
to the control that should be queried for errors.
`string` | (`string` \| `number`)[]
### Returns
`boolean`
whether the given error is present in the control at the given path.
If the control is not present, false is returned.
### Description
Reports whether the control with the given path has the error specified.
### Usage Notes
For example, for the following `FormGroup`:
```ts
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.
### Inherited from
`NgAbstractControl.hasError`
***
## hasValidator()
**hasValidator**(`validator`): `boolean`
Defined in: node\_modules/@angular/forms/index.d.ts:2418
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
#### validator
`ValidatorFn`
The validator to check for presence. Compared by function reference.
### Returns
`boolean`
Whether the provided validator was found on this control.
### Usage Notes
## Reference to a ValidatorFn
```
// Reference to the RequiredValidator
const ctrl = new FormControl<number | null>(0, Validators.required);
expect(ctrl.hasValidator(Validators.required)).toEqual(true)
// Reference to anonymous function inside MinValidator
const minValidator = Validators.min(3);
const ctrl = new FormControl<number | null>(0, minValidator);
expect(ctrl.hasValidator(minValidator)).toEqual(true)
expect(ctrl.hasValidator(Validators.min(3))).toEqual(false)
```
### Inherited from
`NgAbstractControl.hasValidator`
***
## markAllAsTouched()
**markAllAsTouched**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2474
Marks the control and all its descendant controls as `touched`.
### Parameters
#### opts?
Configuration options that determine how the control propagates changes
and emits events after marking is applied.
* `emitEvent`: When true or not supplied (the default), the `events`
observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
When false, no events are emitted.
##### emitEvent?
`boolean`
### Returns
`void`
### See
[()](AbstractControl.md#markastouched)
### Inherited from
`NgAbstractControl.markAllAsTouched`
***
## markAsDirty()
**markAsDirty**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2515
Marks the control as `dirty`. A control becomes dirty when
the control's value is changed through the UI; compare `markAsTouched`.
### Parameters
#### opts?
Configuration 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 `events`
observable emits a `PristineChangeEvent` with the `pristine` property being `false`.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
- [()](AbstractControl.md#markastouched)
- [()](AbstractControl.md#markasuntouched)
- [()](AbstractControl.md#markaspristine)
### Inherited from
`NgAbstractControl.markAsDirty`
***
## markAsPending()
**markAsPending**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2559
Marks the control as `pending`.
A control is pending while the control performs async validation.
### Parameters
#### opts?
Configuration 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
and the `events` observable emits a `StatusChangeEvent` with the `status` property being
`PENDING` When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
[AbstractControl.status](AbstractControl.md#status)
### Inherited from
`NgAbstractControl.markAsPending`
***
## markAsPristine()
**markAsPristine**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2538
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.
### Parameters
#### opts?
Configuration 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.
* `emitEvent`: When true or not supplied (the default), the `events`
observable emits a `PristineChangeEvent` with the `pristine` property being `true`.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
- [()](AbstractControl.md#markastouched)
- [()](AbstractControl.md#markasuntouched)
- [()](AbstractControl.md#markasdirty)
### Inherited from
`NgAbstractControl.markAsPristine`
***
## markAsTouched()
**markAsTouched**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2460
Marks the control as `touched`. A control is touched by focus and
blur events that do not change the value.
### Parameters
#### opts?
Configuration 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 `events`
observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
- [()](AbstractControl.md#markasuntouched)
- [()](AbstractControl.md#markasdirty)
- [()](AbstractControl.md#markaspristine)
### Inherited from
`NgAbstractControl.markAsTouched`
***
## markAsUntouched()
**markAsUntouched**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2495
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.
### Parameters
#### opts?
Configuration 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.
* `emitEvent`: When true or not supplied (the default), the `events`
observable emits a `TouchedChangeEvent` with the `touched` property being `false`.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### See
- [()](AbstractControl.md#markastouched)
- [()](AbstractControl.md#markasdirty)
- [()](AbstractControl.md#markaspristine)
### Inherited from
`NgAbstractControl.markAsUntouched`
***
## patchValue()
`abstract` **patchValue**(`value`, `options`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2620
Patches the value of the control. Abstract method (implemented in sub-classes).
### Parameters
#### value
`any`
#### options?
`Object`
### Returns
`void`
### Inherited from
`NgAbstractControl.patchValue`
***
## removeAsyncValidators()
**removeAsyncValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2394
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
#### validators
The asynchronous validator or validators to remove.
`AsyncValidatorFn` | `AsyncValidatorFn`[]
### Returns
`void`
### Inherited from
`NgAbstractControl.removeAsyncValidators`
***
## removeValidators()
**removeValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2382
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.
### Parameters
#### validators
The validator or validators to remove.
`ValidatorFn` | `ValidatorFn`[]
### Returns
`void`
### Usage Notes
## Reference to a ValidatorFn
```
// Reference to the RequiredValidator
const ctrl = new FormControl<string | null>('', Validators.required);
ctrl.removeValidators(Validators.required);
// Reference to anonymous function inside MinValidator
const minValidator = Validators.min(3);
const ctrl = new FormControl<string | null>('', minValidator);
expect(ctrl.hasValidator(minValidator)).toEqual(true)
expect(ctrl.hasValidator(Validators.min(3))).toEqual(false)
ctrl.removeValidators(minValidator);
```
When you add or remove a validator at run time, you must call
`updateValueAndValidity()` for the new validation to take effect.
### Inherited from
`NgAbstractControl.removeValidators`
***
## reset()
`abstract` **reset**(`value`?, `options`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2624
Resets the control. Abstract method (implemented in sub-classes).
### Parameters
#### value?
`any`
#### options?
`Object`
### Returns
`void`
### Inherited from
`NgAbstractControl.reset`
***
## setAsyncValidators()
**setAsyncValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2327
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
#### validators
`null` | `AsyncValidatorFn` | `AsyncValidatorFn`[]
### Returns
`void`
### Inherited from
`NgAbstractControl.setAsyncValidators`
***
## setErrors()
**setErrors**(`errors`, `opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2680
Sets errors on a form control when running validations manually, rather than automatically.
Calling `setErrors` also updates the validity of the parent control.
### Parameters
#### errors
`null` | `ValidationErrors`
#### opts?
Configuration options that determine how the control propagates
changes and emits events after the control errors are set.
* `emitEvent`: When true or not supplied (the default), the `statusChanges`
observable emits an event after the errors are set.
##### emitEvent?
`boolean`
### Returns
`void`
### Usage Notes
## Manually set the errors for a control
```ts
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);
```
### Inherited from
`NgAbstractControl.setErrors`
***
## setParent()
**setParent**(`parent`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2612
Sets the parent of the control
### Parameters
#### parent
The new parent.
`null` | `FormGroup`\<`any`\> | `FormArray`\<`any`\>
### Returns
`void`
### Inherited from
`NgAbstractControl.setParent`
***
## setValidators()
**setValidators**(`validators`): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2316
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
#### validators
`null` | `ValidatorFn` | `ValidatorFn`[]
### Returns
`void`
### Inherited from
`NgAbstractControl.setValidators`
***
## setValue()
`abstract` **setValue**(`value`, `options`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2616
Sets the value of the control. Abstract method (implemented in sub-classes).
### Parameters
#### value
`any`
#### options?
`Object`
### Returns
`void`
### Inherited from
`NgAbstractControl.setValue`
***
## updateValueAndValidity()
**updateValueAndValidity**(`opts`?): `void`
Defined in: node\_modules/@angular/forms/index.d.ts:2644
Recalculates the value and validation status of the control.
By default, it also updates the value and validity of its ancestors.
### Parameters
#### opts?
Configuration 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), the `statusChanges`,
`valueChanges` and `events`
observables emit events with the latest status and value when the control is updated.
When false, no events are emitted.
##### emitEvent?
`boolean`
##### onlySelf?
`boolean`
### Returns
`void`
### Inherited from
`NgAbstractControl.updateValueAndValidity`