arlas-web-components / Exports / PointFormGroup
Class: PointFormGroup
Hierarchy
FormGroup
↳ PointFormGroup
Table of contents
Constructors
Properties
- controls
- errors
- latitude
- latitudeChanges$
- longitude
- longitudesChanges$
- pristine
- status
- statusChanges
- touched
- value
- valueChanges
Accessors
- asyncValidator
- dirty
- disabled
- enabled
- invalid
- parent
- pending
- root
- untouched
- updateOn
- valid
- validator
Methods
- addAsyncValidators
- addControl
- addValidators
- clearAsyncValidators
- clearValidators
- contains
- disable
- enable
- get
- getError
- getRawValue
- hasAsyncValidator
- hasError
- hasValidator
- markAllAsTouched
- markAsDirty
- markAsPending
- markAsPristine
- markAsTouched
- markAsUntouched
- patchValue
- registerControl
- removeAsyncValidators
- removeControl
- removeValidators
- reset
- setAsyncValidators
- setControl
- setErrors
- setParent
- setValidators
- setValue
- updateValueAndValidity
Constructors
constructor
• new PointFormGroup(initLat
, initLng
)
Parameters
Name | Type |
---|---|
initLat |
string | number |
initLng |
string | number |
Overrides
FormGroup.constructor
Defined in
projects/arlas-components/src/lib/tools/coordinates.tools.ts:33
Properties
controls
• controls: Object
Index signature
▪ [key: string
]: AbstractControl
<any
>
Inherited from
FormGroup.controls
Defined in
node_modules/@angular/forms/index.d.ts:2566
errors
• Readonly
errors: ValidationErrors
An object containing any errors generated by failing validation, or null if there are no errors.
Inherited from
FormGroup.errors
Defined in
node_modules/@angular/forms/index.d.ts:147
latitude
• latitude: FormControl
<any
>
Defined in
projects/arlas-components/src/lib/tools/coordinates.tools.ts:27
latitudeChanges$
• latitudeChanges$: Observable
<any
>
Defined in
projects/arlas-components/src/lib/tools/coordinates.tools.ts:30
longitude
• longitude: FormControl
<any
>
Defined in
projects/arlas-components/src/lib/tools/coordinates.tools.ts:28
longitudesChanges$
• longitudesChanges$: Observable
<any
>
Defined in
projects/arlas-components/src/lib/tools/coordinates.tools.ts:31
pristine
• Readonly
pristine: boolean
A control is pristine
if the user has not yet changed
the value in the UI.
Inherited from
FormGroup.pristine
Defined in
node_modules/@angular/forms/index.d.ts:155
status
• Readonly
status: FormControlStatus
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.
Inherited from
FormGroup.status
Defined in
node_modules/@angular/forms/index.d.ts:93
statusChanges
• Readonly
statusChanges: Observable
<FormControlStatus
>
A multicasting observable that emits an event every time the validation status
of the control
recalculates.
See
FormControlStatus
- AbstractControl.status
Inherited from
FormGroup.statusChanges
Defined in
node_modules/@angular/forms/index.d.ts:192
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
FormGroup.touched
Defined in
node_modules/@angular/forms/index.d.ts:170
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
FormGroup.value
Defined in
node_modules/@angular/forms/index.d.ts:57
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
FormGroup.valueChanges
Defined in
node_modules/@angular/forms/index.d.ts:183
Accessors
asyncValidator
• get
asyncValidator(): 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
AsyncValidatorFn
Inherited from
FormGroup.asyncValidator
Defined in
node_modules/@angular/forms/index.d.ts:79
• set
asyncValidator(asyncValidatorFn
): void
Parameters
Name | Type |
---|---|
asyncValidatorFn |
AsyncValidatorFn |
Returns
void
Inherited from
FormGroup.asyncValidator
Defined in
node_modules/@angular/forms/index.d.ts:80
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
FormGroup.dirty
Defined in
node_modules/@angular/forms/index.d.ts:163
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
AbstractControl.status
Returns
boolean
True if the control is disabled, false otherwise.
Inherited from
FormGroup.disabled
Defined in
node_modules/@angular/forms/index.d.ts:132
enabled
• get
enabled(): boolean
A control is enabled
as long as its status
is not DISABLED
.
See
AbstractControl.status
Returns
boolean
True if the control has any status other than 'DISABLED', false if the status is 'DISABLED'.
Inherited from
FormGroup.enabled
Defined in
node_modules/@angular/forms/index.d.ts:142
invalid
• get
invalid(): boolean
A control is invalid
when its status
is INVALID
.
See
AbstractControl.status
Returns
boolean
True if this control has failed one or more of its validation checks, false otherwise.
Inherited from
FormGroup.invalid
Defined in
node_modules/@angular/forms/index.d.ts:111
parent
• get
parent(): FormGroup
<any
> | FormArray
<any
>
The parent control.
Returns
FormGroup
<any
> | FormArray
<any
>
Inherited from
FormGroup.parent
Defined in
node_modules/@angular/forms/index.d.ts:84
pending
• get
pending(): boolean
A control is pending
when its status
is PENDING
.
See
AbstractControl.status
Returns
boolean
True if this control is in the process of conducting a validation check, false otherwise.
Inherited from
FormGroup.pending
Defined in
node_modules/@angular/forms/index.d.ts:120
root
• get
root(): AbstractControl
<any
, any
>
Retrieves the top-level ancestor of this control.
Returns
AbstractControl
<any
, any
>
Inherited from
FormGroup.root
Defined in
node_modules/@angular/forms/index.d.ts:627
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
FormGroup.untouched
Defined in
node_modules/@angular/forms/index.d.ts:177
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
FormGroup.updateOn
Defined in
node_modules/@angular/forms/index.d.ts:199
valid
• get
valid(): boolean
A control is valid
when its status
is VALID
.
See
AbstractControl.status
Returns
boolean
True if the control has passed all of its validation tests, false otherwise.
Inherited from
FormGroup.valid
Defined in
node_modules/@angular/forms/index.d.ts:102
validator
• get
validator(): 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
ValidatorFn
Inherited from
FormGroup.validator
Defined in
node_modules/@angular/forms/index.d.ts:72
• set
validator(validatorFn
): void
Parameters
Name | Type |
---|---|
validatorFn |
ValidatorFn |
Returns
void
Inherited from
FormGroup.validator
Defined in
node_modules/@angular/forms/index.d.ts:73
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
Name | Type | Description |
---|---|---|
validators |
AsyncValidatorFn | AsyncValidatorFn [] |
The new asynchronous validator function or functions to add to this control. |
Returns
void
Inherited from
FormGroup.addAsyncValidators
Defined in
node_modules/@angular/forms/index.d.ts:246
addControl
▸ addControl(this
, name
, control
, options?
): void
Add a control to this group. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).
If a control with a given name already exists, it would not be replaced with a new one. If you want to replace an existing control, use the FormGroup#setControl setControl method instead. This method also updates the value and validity of the control.
Parameters
Name | Type | Description |
---|---|---|
this |
FormGroup <{ [key: string] : AbstractControl <any >; }> |
- |
name |
string |
The control name to add to the collection |
control |
AbstractControl <any , any > |
Provides the control for the given name |
options? |
Object |
Specifies whether this FormGroup instance should emit events after a new control is added. * 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 added. When false, no events are emitted. |
options.emitEvent? |
boolean |
- |
Returns
void
Inherited from
FormGroup.addControl
Defined in
node_modules/@angular/forms/index.d.ts:2599
▸ addControl<K
>(name
, control
, options?
): void
Type parameters
Name | Type |
---|---|
K |
extends string |
Parameters
Name | Type |
---|---|
name |
K |
control |
any |
options? |
Object |
options.emitEvent? |
boolean |
Returns
void
Inherited from
FormGroup.addControl
Defined in
node_modules/@angular/forms/index.d.ts:2604
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
Name | Type | Description |
---|---|---|
validators |
ValidatorFn | ValidatorFn [] |
The new validator function or functions to add to this control. |
Returns
void
Inherited from
FormGroup.addValidators
Defined in
node_modules/@angular/forms/index.d.ts:234
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
FormGroup.clearAsyncValidators
Defined in
node_modules/@angular/forms/index.d.ts:337
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
FormGroup.clearValidators
Defined in
node_modules/@angular/forms/index.d.ts:329
contains
▸ contains<K
>(controlName
): boolean
Check whether there is an enabled control with the given name in the group.
Reports false for disabled controls. If you'd like to check for existence in the group only, use AbstractControl#get get instead.
Type parameters
Name | Type |
---|---|
K |
extends string |
Parameters
Name | Type | Description |
---|---|---|
controlName |
K |
The control name to check for existence in the collection |
Returns
boolean
false for disabled controls, true otherwise.
Inherited from
FormGroup.contains
Defined in
node_modules/@angular/forms/index.d.ts:2647
▸ contains(this
, controlName
): boolean
Parameters
Name | Type |
---|---|
this |
FormGroup <{ [key: string] : AbstractControl <any >; }> |
controlName |
string |
Returns
boolean
Inherited from
FormGroup.contains
Defined in
node_modules/@angular/forms/index.d.ts:2648
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
AbstractControl.status
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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), 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
FormGroup.disable
Defined in
node_modules/@angular/forms/index.d.ts:449
enable
▸ enable(opts?
): void
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.
See
AbstractControl.status
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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), both the statusChanges and valueChanges observables emit events with the latest status and value when the control is enabled. When false, no events are emitted. |
opts.emitEvent? |
boolean |
- |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.enable
Defined in
node_modules/@angular/forms/index.d.ts:471
get
▸ get<P
>(path
): AbstractControl
<ɵGetProperty
<any
, P
>, ɵGetProperty
<any
, P
>>
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
Name | Type |
---|---|
P |
extends string | readonly (string | number )[] |
Parameters
Name | Type |
---|---|
path |
P |
Returns
AbstractControl
<ɵGetProperty
<any
, P
>, ɵGetProperty
<any
, P
>>
Inherited from
FormGroup.get
Defined in
node_modules/@angular/forms/index.d.ts:557
▸ get<P
>(path
): AbstractControl
<ɵGetProperty
<any
, P
>, ɵGetProperty
<any
, P
>>
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
Name | Type |
---|---|
P |
extends string | (string | number )[] |
Parameters
Name | Type |
---|---|
path |
P |
Returns
AbstractControl
<ɵGetProperty
<any
, P
>, ɵGetProperty
<any
, P
>>
Inherited from
FormGroup.get
Defined in
node_modules/@angular/forms/index.d.ts:564
getError
▸ getError(errorCode
, path?
): any
Description
Reports error data for the control with the given path.
Usage Notes
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:
- An array of string control names, e.g.
['address', 'street']
- A period-delimited list of control names in one string, e.g.
'address.street'
Parameters
Name | Type | Description |
---|---|---|
errorCode |
string |
The 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
FormGroup.getError
Defined in
node_modules/@angular/forms/index.d.ts:592
getRawValue
▸ getRawValue(): any
The aggregate value of the FormGroup
, including any disabled controls.
Retrieves all values regardless of disabled status.
Returns
any
Inherited from
FormGroup.getRawValue
Defined in
node_modules/@angular/forms/index.d.ts:2791
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
Name | Type | Description |
---|---|---|
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
FormGroup.hasAsyncValidator
Defined in
node_modules/@angular/forms/index.d.ts:321
hasError
▸ hasError(errorCode
, path?
): boolean
Description
Reports whether the control with the given path has the error specified.
Usage Notes
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:
- An array of string control names, e.g.
['address', 'street']
- 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
Name | Type | Description |
---|---|---|
errorCode |
string |
The 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
FormGroup.hasError
Defined in
node_modules/@angular/forms/index.d.ts:623
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.
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)
Parameters
Name | Type | Description |
---|---|---|
validator |
ValidatorFn |
The validator to check for presence. Compared by function reference. |
Returns
boolean
Whether the provided validator was found on this control.
Inherited from
FormGroup.hasValidator
Defined in
node_modules/@angular/forms/index.d.ts:312
markAllAsTouched
▸ markAllAsTouched(): void
Marks the control and all its descendant controls as touched
.
See
markAsTouched()
Returns
void
Inherited from
FormGroup.markAllAsTouched
Defined in
node_modules/@angular/forms/index.d.ts:358
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()
markAsUntouched()
markAsPristine()
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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. |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.markAsDirty
Defined in
node_modules/@angular/forms/index.d.ts:390
markAsPending
▸ markAsPending(opts?
): void
Marks the control as pending
.
A control is pending while the control performs async validation.
See
AbstractControl.status
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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. When false, no events are emitted. |
opts.emitEvent? |
boolean |
- |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.markAsPending
Defined in
node_modules/@angular/forms/index.d.ts:428
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()
markAsUntouched()
markAsDirty()
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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. |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.markAsPristine
Defined in
node_modules/@angular/forms/index.d.ts:409
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()
markAsDirty()
markAsPristine()
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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. |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.markAsTouched
Defined in
node_modules/@angular/forms/index.d.ts:351
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()
markAsDirty()
markAsPristine()
Parameters
Name | Type | Description |
---|---|---|
opts? |
Object |
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. |
opts.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.markAsUntouched
Defined in
node_modules/@angular/forms/index.d.ts:374
patchValue
▸ patchValue(value
, options?
): void
Patches the value of the FormGroup
. It accepts an object with control
names as keys, and does its best to match the values to the correct controls
in the group.
It accepts both super-sets and sub-sets of the group without throwing an error.
Usage Notes
Patch the value for a form group
const form = new FormGroup({
first: new FormControl(),
last: new FormControl()
});
console.log(form.value); // {first: null, last: null}
form.patchValue({first: 'Nancy'});
console.log(form.value); // {first: 'Nancy', last: null}
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The object that matches the structure of the group. |
options? |
Object |
Configuration options that determine how the control propagates changes and emits events after the value is patched. * onlySelf : When true, each change only affects this control and not its parent. Default is true. * 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. The configuration options are passed to the AbstractControl#updateValueAndValidity updateValueAndValidity method. |
options.emitEvent? |
boolean |
- |
options.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.patchValue
Defined in
node_modules/@angular/forms/index.d.ts:2721
registerControl
▸ registerControl<K
>(name
, control
): any
Registers a control with the group's list of controls. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).
This method does not update the value or validity of the control. Use FormGroup#addControl addControl instead.
Type parameters
Name | Type |
---|---|
K |
extends string |
Parameters
Name | Type | Description |
---|---|---|
name |
K |
The control name to register in the collection |
control |
any |
Provides the control for the given name |
Returns
any
Inherited from
FormGroup.registerControl
Defined in
node_modules/@angular/forms/index.d.ts:2579
▸ registerControl(this
, name
, control
): AbstractControl
<any
, any
>
Parameters
Name | Type |
---|---|
this |
FormGroup <{ [key: string] : AbstractControl <any >; }> |
name |
string |
control |
AbstractControl <any , any > |
Returns
AbstractControl
<any
, any
>
Inherited from
FormGroup.registerControl
Defined in
node_modules/@angular/forms/index.d.ts:2580
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
Name | Type | Description |
---|---|---|
validators |
AsyncValidatorFn | AsyncValidatorFn [] |
The asynchronous validator or validators to remove. |
Returns
void
Inherited from
FormGroup.removeAsyncValidators
Defined in
node_modules/@angular/forms/index.d.ts:288
removeControl
▸ removeControl(this
, name
, options?
): void
Parameters
Name | Type |
---|---|
this |
FormGroup <{ [key: string] : AbstractControl <any >; }> |
name |
string |
options? |
Object |
options.emitEvent? |
boolean |
Returns
void
Inherited from
FormGroup.removeControl
Defined in
node_modules/@angular/forms/index.d.ts:2607
▸ removeControl<S
>(name
, options?
): void
Type parameters
Name | Type |
---|---|
S |
extends string |
Parameters
Name | Type |
---|---|
name |
string & S |
options? |
Object |
options.emitEvent? |
boolean |
Returns
void
Inherited from
FormGroup.removeControl
Defined in
node_modules/@angular/forms/index.d.ts:2612
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.
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.
Parameters
Name | Type | Description |
---|---|---|
validators |
ValidatorFn | ValidatorFn [] |
The validator or validators to remove. |
Returns
void
Inherited from
FormGroup.removeValidators
Defined in
node_modules/@angular/forms/index.d.ts:276
reset
▸ reset(value?
, options?
): void
Resets the FormGroup
, marks all descendants pristine
and untouched
and sets
the value of all descendants to their default values, or null if no defaults were provided.
You reset to a specific form state by passing in a map of states that matches the structure of your form, with control names as keys. The state is a standalone value or a form state object with both a value and a disabled status.
Usage Notes
Reset the form group values
const form = new FormGroup({
first: new FormControl('first name'),
last: new FormControl('last name')
});
console.log(form.value); // {first: 'first name', last: 'last name'}
form.reset({ first: 'name', last: 'last name' });
console.log(form.value); // {first: 'name', last: 'last name'}
Reset the form group values and disabled status
const form = new FormGroup({
first: new FormControl('first name'),
last: new FormControl('last name')
});
form.reset({
first: {value: 'name', disabled: true},
last: 'last'
});
console.log(form.value); // {last: 'last'}
console.log(form.get('first').status); // 'DISABLED'
Parameters
Name | Type | Description |
---|---|---|
value? |
any |
Resets the control with an initial value, or an object that defines the initial value and disabled state. |
options? |
Object |
Configuration options that determine how the control propagates changes and emits events when the group is reset. * 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. The configuration options are passed to the AbstractControl#updateValueAndValidity updateValueAndValidity method. |
options.emitEvent? |
boolean |
- |
options.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.reset
Defined in
node_modules/@angular/forms/index.d.ts:2782
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
Name | Type |
---|---|
validators |
AsyncValidatorFn | AsyncValidatorFn [] |
Returns
void
Inherited from
FormGroup.setAsyncValidators
Defined in
node_modules/@angular/forms/index.d.ts:221
setControl
▸ setControl<K
>(name
, control
, options?
): void
Replace an existing control. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).
If a control with a given name does not exist in this FormGroup
, it will be added.
Type parameters
Name | Type |
---|---|
K |
extends string |
Parameters
Name | Type | Description |
---|---|---|
name |
K |
The control name to replace in the collection |
control |
any |
Provides the control for the given name |
options? |
Object |
Specifies whether this FormGroup instance should emit events after an existing control is replaced. * 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 replaced with a new one. When false, no events are emitted. |
options.emitEvent? |
boolean |
- |
Returns
void
Inherited from
FormGroup.setControl
Defined in
node_modules/@angular/forms/index.d.ts:2629
▸ setControl(this
, name
, control
, options?
): void
Parameters
Name | Type |
---|---|
this |
FormGroup <{ [key: string] : AbstractControl <any >; }> |
name |
string |
control |
AbstractControl <any , any > |
options? |
Object |
options.emitEvent? |
boolean |
Returns
void
Inherited from
FormGroup.setControl
Defined in
node_modules/@angular/forms/index.d.ts:2632
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.
Usage Notes
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
Name | Type | Description |
---|---|---|
errors |
ValidationErrors |
- |
opts? |
Object |
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. |
opts.emitEvent? |
boolean |
- |
Returns
void
Inherited from
FormGroup.setErrors
Defined in
node_modules/@angular/forms/index.d.ts:549
setParent
▸ setParent(parent
): void
Sets the parent of the control
Parameters
Name | Type | Description |
---|---|---|
parent |
FormGroup <any > | FormArray <any > |
The new parent. |
Returns
void
Inherited from
FormGroup.setParent
Defined in
node_modules/@angular/forms/index.d.ts:481
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
Name | Type |
---|---|
validators |
ValidatorFn | ValidatorFn [] |
Returns
void
Inherited from
FormGroup.setValidators
Defined in
node_modules/@angular/forms/index.d.ts:210
setValue
▸ setValue(value
, options?
): void
Sets the value of the FormGroup
. It accepts an object that matches
the structure of the group, with control names as keys.
Usage Notes
Set the complete value for the form group
const form = new FormGroup({
first: new FormControl(),
last: new FormControl()
});
console.log(form.value); // {first: null, last: null}
form.setValue({first: 'Nancy', last: 'Drew'});
console.log(form.value); // {first: 'Nancy', last: 'Drew'}
Throws
When strict checks fail, such as setting the value of a control that doesn't exist or if you exclude a value of a control that does exist.
Parameters
Name | Type | Description |
---|---|---|
value |
Object |
The new value for the control that matches the structure of the group. |
options? |
Object |
Configuration options that determine how the control propagates changes and emits events after the value changes. The configuration options are passed to the 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. |
options.emitEvent? |
boolean |
- |
options.onlySelf? |
boolean |
- |
Returns
void
Inherited from
FormGroup.setValue
Defined in
node_modules/@angular/forms/index.d.ts:2686
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
Name | Type | Description |
---|---|---|
opts? |
Object |
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), 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
FormGroup.updateValueAndValidity
Defined in
node_modules/@angular/forms/index.d.ts:513