1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { Observable } from 'rxjs/Observable';
|
9
|
import { AbstractControl } from '../model';
|
10
|
import { ValidationErrors } from './validators';
|
11
|
/**
|
12
|
* Base class for control directives.
|
13
|
*
|
14
|
* Only used internally in the forms module.
|
15
|
*
|
16
|
* @stable
|
17
|
*/
|
18
|
export declare abstract class AbstractControlDirective {
|
19
|
/**
|
20
|
* The {@link FormControl}, {@link FormGroup}, or {@link FormArray}
|
21
|
* that backs this directive. Most properties fall through to that
|
22
|
* instance.
|
23
|
*/
|
24
|
readonly abstract control: AbstractControl | null;
|
25
|
/** The value of the control. */
|
26
|
readonly value: any;
|
27
|
/**
|
28
|
* A control is `valid` when its `status === VALID`.
|
29
|
*
|
30
|
* In order to have this status, the control must have passed all its
|
31
|
* validation checks.
|
32
|
*/
|
33
|
readonly valid: boolean | null;
|
34
|
/**
|
35
|
* A control is `invalid` when its `status === INVALID`.
|
36
|
*
|
37
|
* In order to have this status, the control must have failed
|
38
|
* at least one of its validation checks.
|
39
|
*/
|
40
|
readonly invalid: boolean | null;
|
41
|
/**
|
42
|
* A control is `pending` when its `status === PENDING`.
|
43
|
*
|
44
|
* In order to have this status, the control must be in the
|
45
|
* middle of conducting a validation check.
|
46
|
*/
|
47
|
readonly pending: boolean | null;
|
48
|
/**
|
49
|
* A control is `disabled` when its `status === DISABLED`.
|
50
|
*
|
51
|
* Disabled controls are exempt from validation checks and
|
52
|
* are not included in the aggregate value of their ancestor
|
53
|
* controls.
|
54
|
*/
|
55
|
readonly disabled: boolean | null;
|
56
|
/**
|
57
|
* A control is `enabled` as long as its `status !== DISABLED`.
|
58
|
*
|
59
|
* In other words, it has a status of `VALID`, `INVALID`, or
|
60
|
* `PENDING`.
|
61
|
*/
|
62
|
readonly enabled: boolean | null;
|
63
|
/**
|
64
|
* Returns any errors generated by failing validation. If there
|
65
|
* are no errors, it will return null.
|
66
|
*/
|
67
|
readonly errors: ValidationErrors | null;
|
68
|
/**
|
69
|
* A control is `pristine` if the user has not yet changed
|
70
|
* the value in the UI.
|
71
|
*
|
72
|
* Note that programmatic changes to a control's value will
|
73
|
* *not* mark it dirty.
|
74
|
*/
|
75
|
readonly pristine: boolean | null;
|
76
|
/**
|
77
|
* A control is `dirty` if the user has changed the value
|
78
|
* in the UI.
|
79
|
*
|
80
|
* Note that programmatic changes to a control's value will
|
81
|
* *not* mark it dirty.
|
82
|
*/
|
83
|
readonly dirty: boolean | null;
|
84
|
/**
|
85
|
* A control is marked `touched` once the user has triggered
|
86
|
* a `blur` event on it.
|
87
|
*/
|
88
|
readonly touched: boolean | null;
|
89
|
/**
|
90
|
* A control is `untouched` if the user has not yet triggered
|
91
|
* a `blur` event on it.
|
92
|
*/
|
93
|
readonly untouched: boolean | null;
|
94
|
/**
|
95
|
* Emits an event every time the validation status of the control
|
96
|
* is re-calculated.
|
97
|
*/
|
98
|
readonly statusChanges: Observable<any> | null;
|
99
|
/**
|
100
|
* Emits an event every time the value of the control changes, in
|
101
|
* the UI or programmatically.
|
102
|
*/
|
103
|
readonly valueChanges: Observable<any> | null;
|
104
|
/**
|
105
|
* Returns an array that represents the path from the top-level form
|
106
|
* to this control. Each index is the string name of the control on
|
107
|
* that level.
|
108
|
*/
|
109
|
readonly path: string[] | null;
|
110
|
/**
|
111
|
* Resets the form control. This means by default:
|
112
|
*
|
113
|
* * it is marked as `pristine`
|
114
|
* * it is marked as `untouched`
|
115
|
* * value is set to null
|
116
|
*
|
117
|
* For more information, see {@link AbstractControl}.
|
118
|
*/
|
119
|
reset(value?: any): void;
|
120
|
/**
|
121
|
* Returns true if the control with the given path has the error specified. Otherwise
|
122
|
* returns false.
|
123
|
*
|
124
|
* If no path is given, it checks for the error on the present control.
|
125
|
*/
|
126
|
hasError(errorCode: string, path?: string[]): boolean;
|
127
|
/**
|
128
|
* Returns error data if the control with the given path has the error specified. Otherwise
|
129
|
* returns null or undefined.
|
130
|
*
|
131
|
* If no path is given, it checks for the error on the present control.
|
132
|
*/
|
133
|
getError(errorCode: string, path?: string[]): any;
|
134
|
}
|