1 | /**
|
2 | * @license Angular v18.2.2
|
3 | * (c) 2010-2024 Google LLC. https://angular.io/
|
4 | * License: MIT
|
5 | */
|
6 |
|
7 |
|
8 | import { AfterViewInit } from '@angular/core';
|
9 | import { ChangeDetectorRef } from '@angular/core';
|
10 | import { ElementRef } from '@angular/core';
|
11 | import { EventEmitter } from '@angular/core';
|
12 | import * as i0 from '@angular/core';
|
13 | import { InjectionToken } from '@angular/core';
|
14 | import { Injector } from '@angular/core';
|
15 | import { ModuleWithProviders } from '@angular/core';
|
16 | import { Observable } from 'rxjs';
|
17 | import { OnChanges } from '@angular/core';
|
18 | import { OnDestroy } from '@angular/core';
|
19 | import { OnInit } from '@angular/core';
|
20 | import { Provider } from '@angular/core';
|
21 | import { Renderer2 } from '@angular/core';
|
22 | import { SimpleChanges } from '@angular/core';
|
23 | import { Type } from '@angular/core';
|
24 | import { Version } from '@angular/core';
|
25 |
|
26 | /**
|
27 | * This is the base class for `FormControl`, `FormGroup`, and `FormArray`.
|
28 | *
|
29 | * It provides some of the shared behavior that all controls and groups of controls have, like
|
30 | * running validators, calculating status, and resetting state. It also defines the properties
|
31 | * that are shared between all sub-classes, like `value`, `valid`, and `dirty`. It shouldn't be
|
32 | * instantiated directly.
|
33 | *
|
34 | * The first type parameter TValue represents the value type of the control (`control.value`).
|
35 | * The optional type parameter TRawValue represents the raw value type (`control.getRawValue()`).
|
36 | *
|
37 | * @see [Forms Guide](guide/forms)
|
38 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
39 | * @see [Dynamic Forms Guide](guide/forms/dynamic-forms)
|
40 | *
|
41 | * @publicApi
|
42 | */
|
43 | export declare abstract class AbstractControl<TValue = any, TRawValue extends TValue = TValue> {
|
44 | private _parent;
|
45 | private _asyncValidationSubscription;
|
46 | /**
|
47 | * The current value of the control.
|
48 | *
|
49 | * * For a `FormControl`, the current value.
|
50 | * * For an enabled `FormGroup`, the values of enabled controls as an object
|
51 | * with a key-value pair for each member of the group.
|
52 | * * For a disabled `FormGroup`, the values of all controls as an object
|
53 | * with a key-value pair for each member of the group.
|
54 | * * For a `FormArray`, the values of enabled controls as an array.
|
55 | *
|
56 | */
|
57 | readonly value: TValue;
|
58 | /**
|
59 | * Initialize the AbstractControl instance.
|
60 | *
|
61 | * @param validators The function or array of functions that is used to determine the validity of
|
62 | * this control synchronously.
|
63 | * @param asyncValidators The function or array of functions that is used to determine validity of
|
64 | * this control asynchronously.
|
65 | */
|
66 | constructor(validators: ValidatorFn | ValidatorFn[] | null, asyncValidators: AsyncValidatorFn | AsyncValidatorFn[] | null);
|
67 | /**
|
68 | * Returns the function that is used to determine the validity of this control synchronously.
|
69 | * If multiple validators have been added, this will be a single composed function.
|
70 | * See `Validators.compose()` for additional information.
|
71 | */
|
72 | get validator(): ValidatorFn | null;
|
73 | set validator(validatorFn: ValidatorFn | null);
|
74 | /**
|
75 | * Returns the function that is used to determine the validity of this control asynchronously.
|
76 | * If multiple validators have been added, this will be a single composed function.
|
77 | * See `Validators.compose()` for additional information.
|
78 | */
|
79 | get asyncValidator(): AsyncValidatorFn | null;
|
80 | set asyncValidator(asyncValidatorFn: AsyncValidatorFn | null);
|
81 | /**
|
82 | * The parent control.
|
83 | */
|
84 | get parent(): FormGroup | FormArray | null;
|
85 | /**
|
86 | * The validation status of the control.
|
87 | *
|
88 | * @see { FormControlStatus}
|
89 | *
|
90 | * These status values are mutually exclusive, so a control cannot be
|
91 | * both valid AND invalid or invalid AND disabled.
|
92 | */
|
93 | get status(): FormControlStatus;
|
94 | private set status(value);
|
95 | private readonly statusReactive;
|
96 | /**
|
97 | * A control is `valid` when its `status` is `VALID`.
|
98 | *
|
99 | * @see {@link AbstractControl.status}
|
100 | *
|
101 | * @returns True if the control has passed all of its validation tests,
|
102 | * false otherwise.
|
103 | */
|
104 | get valid(): boolean;
|
105 | /**
|
106 | * A control is `invalid` when its `status` is `INVALID`.
|
107 | *
|
108 | * @see {@link AbstractControl.status}
|
109 | *
|
110 | * @returns True if this control has failed one or more of its validation checks,
|
111 | * false otherwise.
|
112 | */
|
113 | get invalid(): boolean;
|
114 | /**
|
115 | * A control is `pending` when its `status` is `PENDING`.
|
116 | *
|
117 | * @see {@link AbstractControl.status}
|
118 | *
|
119 | * @returns True if this control is in the process of conducting a validation check,
|
120 | * false otherwise.
|
121 | */
|
122 | get pending(): boolean;
|
123 | /**
|
124 | * A control is `disabled` when its `status` is `DISABLED`.
|
125 | *
|
126 | * Disabled controls are exempt from validation checks and
|
127 | * are not included in the aggregate value of their ancestor
|
128 | * controls.
|
129 | *
|
130 | * @see {@link AbstractControl.status}
|
131 | *
|
132 | * @returns True if the control is disabled, false otherwise.
|
133 | */
|
134 | get disabled(): boolean;
|
135 | /**
|
136 | * A control is `enabled` as long as its `status` is not `DISABLED`.
|
137 | *
|
138 | * @returns True if the control has any status other than 'DISABLED',
|
139 | * false if the status is 'DISABLED'.
|
140 | *
|
141 | * @see {@link AbstractControl.status}
|
142 | *
|
143 | */
|
144 | get enabled(): boolean;
|
145 | /**
|
146 | * An object containing any errors generated by failing validation,
|
147 | * or null if there are no errors.
|
148 | */
|
149 | readonly errors: ValidationErrors | null;
|
150 | /**
|
151 | * A control is `pristine` if the user has not yet changed
|
152 | * the value in the UI.
|
153 | *
|
154 | * @returns True if the user has not yet changed the value in the UI; compare `dirty`.
|
155 | * Programmatic changes to a control's value do not mark it dirty.
|
156 | */
|
157 | get pristine(): boolean;
|
158 | private set pristine(value);
|
159 | private readonly pristineReactive;
|
160 | /**
|
161 | * A control is `dirty` if the user has changed the value
|
162 | * in the UI.
|
163 | *
|
164 | * @returns True if the user has changed the value of this control in the UI; compare `pristine`.
|
165 | * Programmatic changes to a control's value do not mark it dirty.
|
166 | */
|
167 | get dirty(): boolean;
|
168 | /**
|
169 | * True if the control is marked as `touched`.
|
170 | *
|
171 | * A control is marked `touched` once the user has triggered
|
172 | * a `blur` event on it.
|
173 | */
|
174 | get touched(): boolean;
|
175 | private set touched(value);
|
176 | private readonly touchedReactive;
|
177 | /**
|
178 | * True if the control has not been marked as touched
|
179 | *
|
180 | * A control is `untouched` if the user has not yet triggered
|
181 | * a `blur` event on it.
|
182 | */
|
183 | get untouched(): boolean;
|
184 | /**
|
185 | * A multicasting observable that emits an event every time the state of the control changes.
|
186 | * It emits for value, status, pristine or touched changes.
|
187 | *
|
188 | * **Note**: On value change, the emit happens right after a value of this control is updated. The
|
189 | * value of a parent control (for example if this FormControl is a part of a FormGroup) is updated
|
190 | * later, so accessing a value of a parent control (using the `value` property) from the callback
|
191 | * of this event might result in getting a value that has not been updated yet. Subscribe to the
|
192 | * `events` of the parent control instead.
|
193 | * For other event types, the events are emitted after the parent control has been updated.
|
194 | *
|
195 | */
|
196 | readonly events: Observable<ControlEvent<TValue>>;
|
197 | /**
|
198 | * A multicasting observable that emits an event every time the value of the control changes, in
|
199 | * the UI or programmatically. It also emits an event each time you call enable() or disable()
|
200 | * without passing along {emitEvent: false} as a function argument.
|
201 | *
|
202 | * **Note**: the emit happens right after a value of this control is updated. The value of a
|
203 | * parent control (for example if this FormControl is a part of a FormGroup) is updated later, so
|
204 | * accessing a value of a parent control (using the `value` property) from the callback of this
|
205 | * event might result in getting a value that has not been updated yet. Subscribe to the
|
206 | * `valueChanges` event of the parent control instead.
|
207 | *
|
208 | * TODO: this should be piped from events() but is breaking in G3
|
209 | */
|
210 | readonly valueChanges: Observable<TValue>;
|
211 | /**
|
212 | * A multicasting observable that emits an event every time the validation `status` of the control
|
213 | * recalculates.
|
214 | *
|
215 | * @see {@link FormControlStatus}
|
216 | * @see {@link AbstractControl.status}
|
217 | *
|
218 | * TODO: this should be piped from events() but is breaking in G3
|
219 | */
|
220 | readonly statusChanges: Observable<FormControlStatus>;
|
221 | /**
|
222 | * Reports the update strategy of the `AbstractControl` (meaning
|
223 | * the event on which the control updates itself).
|
224 | * Possible values: `'change'` | `'blur'` | `'submit'`
|
225 | * Default value: `'change'`
|
226 | */
|
227 | get updateOn(): FormHooks;
|
228 | /**
|
229 | * Sets the synchronous validators that are active on this control. Calling
|
230 | * this overwrites any existing synchronous validators.
|
231 | *
|
232 | * When you add or remove a validator at run time, you must call
|
233 | * `updateValueAndValidity()` for the new validation to take effect.
|
234 | *
|
235 | * If you want to add a new validator without affecting existing ones, consider
|
236 | * using `addValidators()` method instead.
|
237 | */
|
238 | setValidators(validators: ValidatorFn | ValidatorFn[] | null): void;
|
239 | /**
|
240 | * Sets the asynchronous validators that are active on this control. Calling this
|
241 | * overwrites any existing asynchronous validators.
|
242 | *
|
243 | * When you add or remove a validator at run time, you must call
|
244 | * `updateValueAndValidity()` for the new validation to take effect.
|
245 | *
|
246 | * If you want to add a new validator without affecting existing ones, consider
|
247 | * using `addAsyncValidators()` method instead.
|
248 | */
|
249 | setAsyncValidators(validators: AsyncValidatorFn | AsyncValidatorFn[] | null): void;
|
250 | /**
|
251 | * Add a synchronous validator or validators to this control, without affecting other validators.
|
252 | *
|
253 | * When you add or remove a validator at run time, you must call
|
254 | * `updateValueAndValidity()` for the new validation to take effect.
|
255 | *
|
256 | * Adding a validator that already exists will have no effect. If duplicate validator functions
|
257 | * are present in the `validators` array, only the first instance would be added to a form
|
258 | * control.
|
259 | *
|
260 | * @param validators The new validator function or functions to add to this control.
|
261 | */
|
262 | addValidators(validators: ValidatorFn | ValidatorFn[]): void;
|
263 | /**
|
264 | * Add an asynchronous validator or validators to this control, without affecting other
|
265 | * validators.
|
266 | *
|
267 | * When you add or remove a validator at run time, you must call
|
268 | * `updateValueAndValidity()` for the new validation to take effect.
|
269 | *
|
270 | * Adding a validator that already exists will have no effect.
|
271 | *
|
272 | * @param validators The new asynchronous validator function or functions to add to this control.
|
273 | */
|
274 | addAsyncValidators(validators: AsyncValidatorFn | AsyncValidatorFn[]): void;
|
275 | /**
|
276 | * Remove a synchronous validator from this control, without affecting other validators.
|
277 | * Validators are compared by function reference; you must pass a reference to the exact same
|
278 | * validator function as the one that was originally set. If a provided validator is not found,
|
279 | * it is ignored.
|
280 | *
|
281 | * @usageNotes
|
282 | *
|
283 | * ### Reference to a ValidatorFn
|
284 | *
|
285 | * ```
|
286 | * // Reference to the RequiredValidator
|
287 | * const ctrl = new FormControl<string | null>('', Validators.required);
|
288 | * ctrl.removeValidators(Validators.required);
|
289 | *
|
290 | * // Reference to anonymous function inside MinValidator
|
291 | * const minValidator = Validators.min(3);
|
292 | * const ctrl = new FormControl<string | null>('', minValidator);
|
293 | * expect(ctrl.hasValidator(minValidator)).toEqual(true)
|
294 | * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false)
|
295 | *
|
296 | * ctrl.removeValidators(minValidator);
|
297 | * ```
|
298 | *
|
299 | * When you add or remove a validator at run time, you must call
|
300 | * `updateValueAndValidity()` for the new validation to take effect.
|
301 | *
|
302 | * @param validators The validator or validators to remove.
|
303 | */
|
304 | removeValidators(validators: ValidatorFn | ValidatorFn[]): void;
|
305 | /**
|
306 | * Remove an asynchronous validator from this control, without affecting other validators.
|
307 | * Validators are compared by function reference; you must pass a reference to the exact same
|
308 | * validator function as the one that was originally set. If a provided validator is not found, it
|
309 | * is ignored.
|
310 | *
|
311 | * When you add or remove a validator at run time, you must call
|
312 | * `updateValueAndValidity()` for the new validation to take effect.
|
313 | *
|
314 | * @param validators The asynchronous validator or validators to remove.
|
315 | */
|
316 | removeAsyncValidators(validators: AsyncValidatorFn | AsyncValidatorFn[]): void;
|
317 | /**
|
318 | * Check whether a synchronous validator function is present on this control. The provided
|
319 | * validator must be a reference to the exact same function that was provided.
|
320 | *
|
321 | * @usageNotes
|
322 | *
|
323 | * ### Reference to a ValidatorFn
|
324 | *
|
325 | * ```
|
326 | * // Reference to the RequiredValidator
|
327 | * const ctrl = new FormControl<number | null>(0, Validators.required);
|
328 | * expect(ctrl.hasValidator(Validators.required)).toEqual(true)
|
329 | *
|
330 | * // Reference to anonymous function inside MinValidator
|
331 | * const minValidator = Validators.min(3);
|
332 | * const ctrl = new FormControl<number | null>(0, minValidator);
|
333 | * expect(ctrl.hasValidator(minValidator)).toEqual(true)
|
334 | * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false)
|
335 | * ```
|
336 | *
|
337 | * @param validator The validator to check for presence. Compared by function reference.
|
338 | * @returns Whether the provided validator was found on this control.
|
339 | */
|
340 | hasValidator(validator: ValidatorFn): boolean;
|
341 | /**
|
342 | * Check whether an asynchronous validator function is present on this control. The provided
|
343 | * validator must be a reference to the exact same function that was provided.
|
344 | *
|
345 | * @param validator The asynchronous validator to check for presence. Compared by function
|
346 | * reference.
|
347 | * @returns Whether the provided asynchronous validator was found on this control.
|
348 | */
|
349 | hasAsyncValidator(validator: AsyncValidatorFn): boolean;
|
350 | /**
|
351 | * Empties out the synchronous validator list.
|
352 | *
|
353 | * When you add or remove a validator at run time, you must call
|
354 | * `updateValueAndValidity()` for the new validation to take effect.
|
355 | *
|
356 | */
|
357 | clearValidators(): void;
|
358 | /**
|
359 | * Empties out the async validator list.
|
360 | *
|
361 | * When you add or remove a validator at run time, you must call
|
362 | * `updateValueAndValidity()` for the new validation to take effect.
|
363 | *
|
364 | */
|
365 | clearAsyncValidators(): void;
|
366 | /**
|
367 | * Marks the control as `touched`. A control is touched by focus and
|
368 | * blur events that do not change the value.
|
369 | *
|
370 | * @see {@link markAsUntouched()}
|
371 | * @see {@link markAsDirty()}
|
372 | * @see {@link markAsPristine()}
|
373 | *
|
374 | * @param opts Configuration options that determine how the control propagates changes
|
375 | * and emits events after marking is applied.
|
376 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
377 | * marks all direct ancestors. Default is false.
|
378 | * * `emitEvent`: When true or not supplied (the default), the `events`
|
379 | * observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
|
380 | * When false, no events are emitted.
|
381 | */
|
382 | markAsTouched(opts?: {
|
383 | onlySelf?: boolean;
|
384 | emitEvent?: boolean;
|
385 | }): void;
|
386 | /**
|
387 | * Marks the control and all its descendant controls as `touched`.
|
388 | * @see {@link markAsTouched()}
|
389 | *
|
390 | * @param opts Configuration options that determine how the control propagates changes
|
391 | * and emits events after marking is applied.
|
392 | * * `emitEvent`: When true or not supplied (the default), the `events`
|
393 | * observable emits a `TouchedChangeEvent` with the `touched` property being `true`.
|
394 | * When false, no events are emitted.
|
395 | */
|
396 | markAllAsTouched(opts?: {
|
397 | emitEvent?: boolean;
|
398 | }): void;
|
399 | /**
|
400 | * Marks the control as `untouched`.
|
401 | *
|
402 | * If the control has any children, also marks all children as `untouched`
|
403 | * and recalculates the `touched` status of all parent controls.
|
404 | *
|
405 | * @see {@link markAsTouched()}
|
406 | * @see {@link markAsDirty()}
|
407 | * @see {@link markAsPristine()}
|
408 | *
|
409 | * @param opts Configuration options that determine how the control propagates changes
|
410 | * and emits events after the marking is applied.
|
411 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
412 | * marks all direct ancestors. Default is false.
|
413 | * * `emitEvent`: When true or not supplied (the default), the `events`
|
414 | * observable emits a `TouchedChangeEvent` with the `touched` property being `false`.
|
415 | * When false, no events are emitted.
|
416 | */
|
417 | markAsUntouched(opts?: {
|
418 | onlySelf?: boolean;
|
419 | emitEvent?: boolean;
|
420 | }): void;
|
421 | /**
|
422 | * Marks the control as `dirty`. A control becomes dirty when
|
423 | * the control's value is changed through the UI; compare `markAsTouched`.
|
424 | *
|
425 | * @see {@link markAsTouched()}
|
426 | * @see {@link markAsUntouched()}
|
427 | * @see {@link markAsPristine()}
|
428 | *
|
429 | * @param opts Configuration options that determine how the control propagates changes
|
430 | * and emits events after marking is applied.
|
431 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
432 | * marks all direct ancestors. Default is false.
|
433 | * * `emitEvent`: When true or not supplied (the default), the `events`
|
434 | * observable emits a `PristineChangeEvent` with the `pristine` property being `false`.
|
435 | * When false, no events are emitted.
|
436 | */
|
437 | markAsDirty(opts?: {
|
438 | onlySelf?: boolean;
|
439 | emitEvent?: boolean;
|
440 | }): void;
|
441 | /**
|
442 | * Marks the control as `pristine`.
|
443 | *
|
444 | * If the control has any children, marks all children as `pristine`,
|
445 | * and recalculates the `pristine` status of all parent
|
446 | * controls.
|
447 | *
|
448 | * @see {@link markAsTouched()}
|
449 | * @see {@link markAsUntouched()}
|
450 | * @see {@link markAsDirty()}
|
451 | *
|
452 | * @param opts Configuration options that determine how the control emits events after
|
453 | * marking is applied.
|
454 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
455 | * marks all direct ancestors. Default is false.
|
456 | * * `emitEvent`: When true or not supplied (the default), the `events`
|
457 | * observable emits a `PristineChangeEvent` with the `pristine` property being `true`.
|
458 | * When false, no events are emitted.
|
459 | */
|
460 | markAsPristine(opts?: {
|
461 | onlySelf?: boolean;
|
462 | emitEvent?: boolean;
|
463 | }): void;
|
464 | /**
|
465 | * Marks the control as `pending`.
|
466 | *
|
467 | * A control is pending while the control performs async validation.
|
468 | *
|
469 | * @see {@link AbstractControl.status}
|
470 | *
|
471 | * @param opts Configuration options that determine how the control propagates changes and
|
472 | * emits events after marking is applied.
|
473 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
474 | * marks all direct ancestors. Default is false.
|
475 | * * `emitEvent`: When true or not supplied (the default), the `statusChanges`
|
476 | * observable emits an event with the latest status the control is marked pending
|
477 | * and the `events` observable emits a `StatusChangeEvent` with the `status` property being
|
478 | * `PENDING` When false, no events are emitted.
|
479 | *
|
480 | */
|
481 | markAsPending(opts?: {
|
482 | onlySelf?: boolean;
|
483 | emitEvent?: boolean;
|
484 | }): void;
|
485 | /**
|
486 | * Disables the control. This means the control is exempt from validation checks and
|
487 | * excluded from the aggregate value of any parent. Its status is `DISABLED`.
|
488 | *
|
489 | * If the control has children, all children are also disabled.
|
490 | *
|
491 | * @see {@link AbstractControl.status}
|
492 | *
|
493 | * @param opts Configuration options that determine how the control propagates
|
494 | * changes and emits events after the control is disabled.
|
495 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
496 | * marks all direct ancestors. Default is false.
|
497 | * * `emitEvent`: When true or not supplied (the default), the `statusChanges`,
|
498 | * `valueChanges` and `events`
|
499 | * observables emit events with the latest status and value when the control is disabled.
|
500 | * When false, no events are emitted.
|
501 | */
|
502 | disable(opts?: {
|
503 | onlySelf?: boolean;
|
504 | emitEvent?: boolean;
|
505 | }): void;
|
506 | /**
|
507 | * Enables the control. This means the control is included in validation checks and
|
508 | * the aggregate value of its parent. Its status recalculates based on its value and
|
509 | * its validators.
|
510 | *
|
511 | * By default, if the control has children, all children are enabled.
|
512 | *
|
513 | * @see {@link AbstractControl.status}
|
514 | *
|
515 | * @param opts Configure options that control how the control propagates changes and
|
516 | * emits events when marked as untouched
|
517 | * * `onlySelf`: When true, mark only this control. When false or not supplied,
|
518 | * marks all direct ancestors. Default is false.
|
519 | * * `emitEvent`: When true or not supplied (the default), the `statusChanges`,
|
520 | * `valueChanges` and `events`
|
521 | * observables emit events with the latest status and value when the control is enabled.
|
522 | * When false, no events are emitted.
|
523 | */
|
524 | enable(opts?: {
|
525 | onlySelf?: boolean;
|
526 | emitEvent?: boolean;
|
527 | }): void;
|
528 | private _updateAncestors;
|
529 | /**
|
530 | * Sets the parent of the control
|
531 | *
|
532 | * @param parent The new parent.
|
533 | */
|
534 | setParent(parent: FormGroup | FormArray | null): void;
|
535 | /**
|
536 | * Sets the value of the control. Abstract method (implemented in sub-classes).
|
537 | */
|
538 | abstract setValue(value: TRawValue, options?: Object): void;
|
539 | /**
|
540 | * Patches the value of the control. Abstract method (implemented in sub-classes).
|
541 | */
|
542 | abstract patchValue(value: TValue, options?: Object): void;
|
543 | /**
|
544 | * Resets the control. Abstract method (implemented in sub-classes).
|
545 | */
|
546 | abstract reset(value?: TValue, options?: Object): void;
|
547 | /**
|
548 | * The raw value of this control. For most control implementations, the raw value will include
|
549 | * disabled children.
|
550 | */
|
551 | getRawValue(): any;
|
552 | /**
|
553 | * Recalculates the value and validation status of the control.
|
554 | *
|
555 | * By default, it also updates the value and validity of its ancestors.
|
556 | *
|
557 | * @param opts Configuration options determine how the control propagates changes and emits events
|
558 | * after updates and validity checks are applied.
|
559 | * * `onlySelf`: When true, only update this control. When false or not supplied,
|
560 | * update all direct ancestors. Default is false.
|
561 | * * `emitEvent`: When true or not supplied (the default), the `statusChanges`,
|
562 | * `valueChanges` and `events`
|
563 | * observables emit events with the latest status and value when the control is updated.
|
564 | * When false, no events are emitted.
|
565 | */
|
566 | updateValueAndValidity(opts?: {
|
567 | onlySelf?: boolean;
|
568 | emitEvent?: boolean;
|
569 | }): void;
|
570 | private _setInitialStatus;
|
571 | private _runValidator;
|
572 | private _runAsyncValidator;
|
573 | private _cancelExistingSubscription;
|
574 | /**
|
575 | * Sets errors on a form control when running validations manually, rather than automatically.
|
576 | *
|
577 | * Calling `setErrors` also updates the validity of the parent control.
|
578 | *
|
579 | * @param opts Configuration options that determine how the control propagates
|
580 | * changes and emits events after the control errors are set.
|
581 | * * `emitEvent`: When true or not supplied (the default), the `statusChanges`
|
582 | * observable emits an event after the errors are set.
|
583 | *
|
584 | * @usageNotes
|
585 | *
|
586 | * ### Manually set the errors for a control
|
587 | *
|
588 | * ```
|
589 | * const login = new FormControl('someLogin');
|
590 | * login.setErrors({
|
591 | * notUnique: true
|
592 | * });
|
593 | *
|
594 | * expect(login.valid).toEqual(false);
|
595 | * expect(login.errors).toEqual({ notUnique: true });
|
596 | *
|
597 | * login.setValue('someOtherLogin');
|
598 | *
|
599 | * expect(login.valid).toEqual(true);
|
600 | * ```
|
601 | */
|
602 | setErrors(errors: ValidationErrors | null, opts?: {
|
603 | emitEvent?: boolean;
|
604 | }): void;
|
605 | /**
|
606 | * Retrieves a child control given the control's name or path.
|
607 | *
|
608 | * This signature for get supports strings and `const` arrays (`.get(['foo', 'bar'] as const)`).
|
609 | */
|
610 | get<P extends string | readonly (string | number)[]>(path: P): AbstractControl<ɵGetProperty<TRawValue, P>> | null;
|
611 | /**
|
612 | * Retrieves a child control given the control's name or path.
|
613 | *
|
614 | * This signature for `get` supports non-const (mutable) arrays. Inferred type
|
615 | * information will not be as robust, so prefer to pass a `readonly` array if possible.
|
616 | */
|
617 | get<P extends string | Array<string | number>>(path: P): AbstractControl<ɵGetProperty<TRawValue, P>> | null;
|
618 | /**
|
619 | * @description
|
620 | * Reports error data for the control with the given path.
|
621 | *
|
622 | * @param errorCode The code of the error to check
|
623 | * @param path A list of control names that designates how to move from the current control
|
624 | * to the control that should be queried for errors.
|
625 | *
|
626 | * @usageNotes
|
627 | * For example, for the following `FormGroup`:
|
628 | *
|
629 | * ```
|
630 | * form = new FormGroup({
|
631 | * address: new FormGroup({ street: new FormControl() })
|
632 | * });
|
633 | * ```
|
634 | *
|
635 | * The path to the 'street' control from the root form would be 'address' -> 'street'.
|
636 | *
|
637 | * It can be provided to this method in one of two formats:
|
638 | *
|
639 | * 1. An array of string control names, e.g. `['address', 'street']`
|
640 | * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
|
641 | *
|
642 | * @returns error data for that particular error. If the control or error is not present,
|
643 | * null is returned.
|
644 | */
|
645 | getError(errorCode: string, path?: Array<string | number> | string): any;
|
646 | /**
|
647 | * @description
|
648 | * Reports whether the control with the given path has the error specified.
|
649 | *
|
650 | * @param errorCode The code of the error to check
|
651 | * @param path A list of control names that designates how to move from the current control
|
652 | * to the control that should be queried for errors.
|
653 | *
|
654 | * @usageNotes
|
655 | * For example, for the following `FormGroup`:
|
656 | *
|
657 | * ```
|
658 | * form = new FormGroup({
|
659 | * address: new FormGroup({ street: new FormControl() })
|
660 | * });
|
661 | * ```
|
662 | *
|
663 | * The path to the 'street' control from the root form would be 'address' -> 'street'.
|
664 | *
|
665 | * It can be provided to this method in one of two formats:
|
666 | *
|
667 | * 1. An array of string control names, e.g. `['address', 'street']`
|
668 | * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
|
669 | *
|
670 | * If no path is given, this method checks for the error on the current control.
|
671 | *
|
672 | * @returns whether the given error is present in the control at the given path.
|
673 | *
|
674 | * If the control is not present, false is returned.
|
675 | */
|
676 | hasError(errorCode: string, path?: Array<string | number> | string): boolean;
|
677 | /**
|
678 | * Retrieves the top-level ancestor of this control.
|
679 | */
|
680 | get root(): AbstractControl;
|
681 | private _calculateStatus;
|
682 | /**
|
683 | * Internal implementation of the `setValidators` method. Needs to be separated out into a
|
684 | * different method, because it is called in the constructor and it can break cases where
|
685 | * a control is extended.
|
686 | */
|
687 | private _assignValidators;
|
688 | /**
|
689 | * Internal implementation of the `setAsyncValidators` method. Needs to be separated out into a
|
690 | * different method, because it is called in the constructor and it can break cases where
|
691 | * a control is extended.
|
692 | */
|
693 | private _assignAsyncValidators;
|
694 | }
|
695 |
|
696 | /**
|
697 | * @description
|
698 | * Base class for control directives.
|
699 | *
|
700 | * This class is only used internally in the `ReactiveFormsModule` and the `FormsModule`.
|
701 | *
|
702 | * @publicApi
|
703 | */
|
704 | export declare abstract class AbstractControlDirective {
|
705 | /**
|
706 | * @description
|
707 | * A reference to the underlying control.
|
708 | *
|
709 | * @returns the control that backs this directive. Most properties fall through to that instance.
|
710 | */
|
711 | abstract get control(): AbstractControl | null;
|
712 | /**
|
713 | * @description
|
714 | * Reports the value of the control if it is present, otherwise null.
|
715 | */
|
716 | get value(): any;
|
717 | /**
|
718 | * @description
|
719 | * Reports whether the control is valid. A control is considered valid if no
|
720 | * validation errors exist with the current value.
|
721 | * If the control is not present, null is returned.
|
722 | */
|
723 | get valid(): boolean | null;
|
724 | /**
|
725 | * @description
|
726 | * Reports whether the control is invalid, meaning that an error exists in the input value.
|
727 | * If the control is not present, null is returned.
|
728 | */
|
729 | get invalid(): boolean | null;
|
730 | /**
|
731 | * @description
|
732 | * Reports whether a control is pending, meaning that async validation is occurring and
|
733 | * errors are not yet available for the input value. If the control is not present, null is
|
734 | * returned.
|
735 | */
|
736 | get pending(): boolean | null;
|
737 | /**
|
738 | * @description
|
739 | * Reports whether the control is disabled, meaning that the control is disabled
|
740 | * in the UI and is exempt from validation checks and excluded from aggregate
|
741 | * values of ancestor controls. If the control is not present, null is returned.
|
742 | */
|
743 | get disabled(): boolean | null;
|
744 | /**
|
745 | * @description
|
746 | * Reports whether the control is enabled, meaning that the control is included in ancestor
|
747 | * calculations of validity or value. If the control is not present, null is returned.
|
748 | */
|
749 | get enabled(): boolean | null;
|
750 | /**
|
751 | * @description
|
752 | * Reports the control's validation errors. If the control is not present, null is returned.
|
753 | */
|
754 | get errors(): ValidationErrors | null;
|
755 | /**
|
756 | * @description
|
757 | * Reports whether the control is pristine, meaning that the user has not yet changed
|
758 | * the value in the UI. If the control is not present, null is returned.
|
759 | */
|
760 | get pristine(): boolean | null;
|
761 | /**
|
762 | * @description
|
763 | * Reports whether the control is dirty, meaning that the user has changed
|
764 | * the value in the UI. If the control is not present, null is returned.
|
765 | */
|
766 | get dirty(): boolean | null;
|
767 | /**
|
768 | * @description
|
769 | * Reports whether the control is touched, meaning that the user has triggered
|
770 | * a `blur` event on it. If the control is not present, null is returned.
|
771 | */
|
772 | get touched(): boolean | null;
|
773 | /**
|
774 | * @description
|
775 | * Reports the validation status of the control. Possible values include:
|
776 | * 'VALID', 'INVALID', 'DISABLED', and 'PENDING'.
|
777 | * If the control is not present, null is returned.
|
778 | */
|
779 | get status(): string | null;
|
780 | /**
|
781 | * @description
|
782 | * Reports whether the control is untouched, meaning that the user has not yet triggered
|
783 | * a `blur` event on it. If the control is not present, null is returned.
|
784 | */
|
785 | get untouched(): boolean | null;
|
786 | /**
|
787 | * @description
|
788 | * Returns a multicasting observable that emits a validation status whenever it is
|
789 | * calculated for the control. If the control is not present, null is returned.
|
790 | */
|
791 | get statusChanges(): Observable<any> | null;
|
792 | /**
|
793 | * @description
|
794 | * Returns a multicasting observable of value changes for the control that emits every time the
|
795 | * value of the control changes in the UI or programmatically.
|
796 | * If the control is not present, null is returned.
|
797 | */
|
798 | get valueChanges(): Observable<any> | null;
|
799 | /**
|
800 | * @description
|
801 | * Returns an array that represents the path from the top-level form to this control.
|
802 | * Each index is the string name of the control on that level.
|
803 | */
|
804 | get path(): string[] | null;
|
805 | /**
|
806 | * Contains the result of merging synchronous validators into a single validator function
|
807 | * (combined using `Validators.compose`).
|
808 | */
|
809 | private _composedValidatorFn;
|
810 | /**
|
811 | * Contains the result of merging asynchronous validators into a single validator function
|
812 | * (combined using `Validators.composeAsync`).
|
813 | */
|
814 | private _composedAsyncValidatorFn;
|
815 | /**
|
816 | * @description
|
817 | * Synchronous validator function composed of all the synchronous validators registered with this
|
818 | * directive.
|
819 | */
|
820 | get validator(): ValidatorFn | null;
|
821 | /**
|
822 | * @description
|
823 | * Asynchronous validator function composed of all the asynchronous validators registered with
|
824 | * this directive.
|
825 | */
|
826 | get asyncValidator(): AsyncValidatorFn | null;
|
827 | private _onDestroyCallbacks;
|
828 | /**
|
829 | * @description
|
830 | * Resets the control with the provided value if the control is present.
|
831 | */
|
832 | reset(value?: any): void;
|
833 | /**
|
834 | * @description
|
835 | * Reports whether the control with the given path has the error specified.
|
836 | *
|
837 | * @param errorCode The code of the error to check
|
838 | * @param path A list of control names that designates how to move from the current control
|
839 | * to the control that should be queried for errors.
|
840 | *
|
841 | * @usageNotes
|
842 | * For example, for the following `FormGroup`:
|
843 | *
|
844 | * ```
|
845 | * form = new FormGroup({
|
846 | * address: new FormGroup({ street: new FormControl() })
|
847 | * });
|
848 | * ```
|
849 | *
|
850 | * The path to the 'street' control from the root form would be 'address' -> 'street'.
|
851 | *
|
852 | * It can be provided to this method in one of two formats:
|
853 | *
|
854 | * 1. An array of string control names, e.g. `['address', 'street']`
|
855 | * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
|
856 | *
|
857 | * If no path is given, this method checks for the error on the current control.
|
858 | *
|
859 | * @returns whether the given error is present in the control at the given path.
|
860 | *
|
861 | * If the control is not present, false is returned.
|
862 | */
|
863 | hasError(errorCode: string, path?: Array<string | number> | string): boolean;
|
864 | /**
|
865 | * @description
|
866 | * Reports error data for the control with the given path.
|
867 | *
|
868 | * @param errorCode The code of the error to check
|
869 | * @param path A list of control names that designates how to move from the current control
|
870 | * to the control that should be queried for errors.
|
871 | *
|
872 | * @usageNotes
|
873 | * For example, for the following `FormGroup`:
|
874 | *
|
875 | * ```
|
876 | * form = new FormGroup({
|
877 | * address: new FormGroup({ street: new FormControl() })
|
878 | * });
|
879 | * ```
|
880 | *
|
881 | * The path to the 'street' control from the root form would be 'address' -> 'street'.
|
882 | *
|
883 | * It can be provided to this method in one of two formats:
|
884 | *
|
885 | * 1. An array of string control names, e.g. `['address', 'street']`
|
886 | * 1. A period-delimited list of control names in one string, e.g. `'address.street'`
|
887 | *
|
888 | * @returns error data for that particular error. If the control or error is not present,
|
889 | * null is returned.
|
890 | */
|
891 | getError(errorCode: string, path?: Array<string | number> | string): any;
|
892 | }
|
893 |
|
894 | /**
|
895 | * Interface for options provided to an `AbstractControl`.
|
896 | *
|
897 | * @publicApi
|
898 | */
|
899 | export declare interface AbstractControlOptions {
|
900 | /**
|
901 | * @description
|
902 | * The list of validators applied to a control.
|
903 | */
|
904 | validators?: ValidatorFn | ValidatorFn[] | null;
|
905 | /**
|
906 | * @description
|
907 | * The list of async validators applied to control.
|
908 | */
|
909 | asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[] | null;
|
910 | /**
|
911 | * @description
|
912 | * The event name for control to update upon.
|
913 | */
|
914 | updateOn?: 'change' | 'blur' | 'submit';
|
915 | }
|
916 |
|
917 | declare class AbstractControlStatus {
|
918 | private _cd;
|
919 | constructor(cd: AbstractControlDirective | null);
|
920 | protected get isTouched(): boolean;
|
921 | protected get isUntouched(): boolean;
|
922 | protected get isPristine(): boolean;
|
923 | protected get isDirty(): boolean;
|
924 | protected get isValid(): boolean;
|
925 | protected get isInvalid(): boolean;
|
926 | protected get isPending(): boolean;
|
927 | protected get isSubmitted(): boolean;
|
928 | }
|
929 |
|
930 | /**
|
931 | * @description
|
932 | * A base class for code shared between the `NgModelGroup` and `FormGroupName` directives.
|
933 | *
|
934 | * @publicApi
|
935 | */
|
936 | export declare class AbstractFormGroupDirective extends ControlContainer implements OnInit, OnDestroy {
|
937 | /** @nodoc */
|
938 | ngOnInit(): void;
|
939 | /** @nodoc */
|
940 | ngOnDestroy(): void;
|
941 | /**
|
942 | * @description
|
943 | * The `FormGroup` bound to this directive.
|
944 | */
|
945 | get control(): FormGroup;
|
946 | /**
|
947 | * @description
|
948 | * The path to this group from the top-level directive.
|
949 | */
|
950 | get path(): string[];
|
951 | /**
|
952 | * @description
|
953 | * The top-level directive for this group if present, otherwise null.
|
954 | */
|
955 | get formDirective(): Form | null;
|
956 | static ɵfac: i0.ɵɵFactoryDeclaration<AbstractFormGroupDirective, never>;
|
957 | static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractFormGroupDirective, never, never, {}, {}, never, never, false, never>;
|
958 | }
|
959 |
|
960 | /**
|
961 | * A base class for Validator-based Directives. The class contains common logic shared across such
|
962 | * Directives.
|
963 | *
|
964 | * For internal use only, this class is not intended for use outside of the Forms package.
|
965 | */
|
966 | declare abstract class AbstractValidatorDirective implements Validator, OnChanges {
|
967 | private _validator;
|
968 | private _onChange;
|
969 | /** @nodoc */
|
970 | ngOnChanges(changes: SimpleChanges): void;
|
971 | /** @nodoc */
|
972 | validate(control: AbstractControl): ValidationErrors | null;
|
973 | /** @nodoc */
|
974 | registerOnValidatorChange(fn: () => void): void;
|
975 | /**
|
976 | * @description
|
977 | * Determines whether this validator should be active or not based on an input.
|
978 | * Base class implementation checks whether an input is defined (if the value is different from
|
979 | * `null` and `undefined`). Validator classes that extend this base class can override this
|
980 | * function with the logic specific to a particular validator directive.
|
981 | */
|
982 | enabled(input: unknown): boolean;
|
983 | static ɵfac: i0.ɵɵFactoryDeclaration<AbstractValidatorDirective, never>;
|
984 | static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractValidatorDirective, never, never, {}, {}, never, never, false, never>;
|
985 | }
|
986 |
|
987 | /**
|
988 | * @description
|
989 | * An interface implemented by classes that perform asynchronous validation.
|
990 | *
|
991 | * @usageNotes
|
992 | *
|
993 | * ### Provide a custom async validator directive
|
994 | *
|
995 | * The following example implements the `AsyncValidator` interface to create an
|
996 | * async validator directive with a custom error key.
|
997 | *
|
998 | * ```typescript
|
999 | * import { of } from 'rxjs';
|
1000 | *
|
1001 | * @Directive({
|
1002 | * selector: '[customAsyncValidator]',
|
1003 | * providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi:
|
1004 | * true}]
|
1005 | * })
|
1006 | * class CustomAsyncValidatorDirective implements AsyncValidator {
|
1007 | * validate(control: AbstractControl): Observable<ValidationErrors|null> {
|
1008 | * return of({'custom': true});
|
1009 | * }
|
1010 | * }
|
1011 | * ```
|
1012 | *
|
1013 | * @publicApi
|
1014 | */
|
1015 | export declare interface AsyncValidator extends Validator {
|
1016 | /**
|
1017 | * @description
|
1018 | * Method that performs async validation against the provided control.
|
1019 | *
|
1020 | * @param control The control to validate against.
|
1021 | *
|
1022 | * @returns A promise or observable that resolves a map of validation errors
|
1023 | * if validation fails, otherwise null.
|
1024 | */
|
1025 | validate(control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null>;
|
1026 | }
|
1027 |
|
1028 | /**
|
1029 | * @description
|
1030 | * A function that receives a control and returns a Promise or observable
|
1031 | * that emits validation errors if present, otherwise null.
|
1032 | *
|
1033 | * @publicApi
|
1034 | */
|
1035 | export declare interface AsyncValidatorFn {
|
1036 | (control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null>;
|
1037 | }
|
1038 |
|
1039 | /**
|
1040 | * Base class for all ControlValueAccessor classes defined in Forms package.
|
1041 | * Contains common logic and utility functions.
|
1042 | *
|
1043 | * Note: this is an *internal-only* class and should not be extended or used directly in
|
1044 | * applications code.
|
1045 | */
|
1046 | declare class BaseControlValueAccessor {
|
1047 | private _renderer;
|
1048 | private _elementRef;
|
1049 | /**
|
1050 | * The registered callback function called when a change or input event occurs on the input
|
1051 | * element.
|
1052 | * @nodoc
|
1053 | */
|
1054 | onChange: (_: any) => void;
|
1055 | /**
|
1056 | * The registered callback function called when a blur event occurs on the input element.
|
1057 | * @nodoc
|
1058 | */
|
1059 | onTouched: () => void;
|
1060 | constructor(_renderer: Renderer2, _elementRef: ElementRef);
|
1061 | /**
|
1062 | * Helper method that sets a property on a target element using the current Renderer
|
1063 | * implementation.
|
1064 | * @nodoc
|
1065 | */
|
1066 | protected setProperty(key: string, value: any): void;
|
1067 | /**
|
1068 | * Registers a function called when the control is touched.
|
1069 | * @nodoc
|
1070 | */
|
1071 | registerOnTouched(fn: () => void): void;
|
1072 | /**
|
1073 | * Registers a function called when the control value changes.
|
1074 | * @nodoc
|
1075 | */
|
1076 | registerOnChange(fn: (_: any) => {}): void;
|
1077 | /**
|
1078 | * Sets the "disabled" property on the range input element.
|
1079 | * @nodoc
|
1080 | */
|
1081 | setDisabledState(isDisabled: boolean): void;
|
1082 | static ɵfac: i0.ɵɵFactoryDeclaration<BaseControlValueAccessor, never>;
|
1083 | static ɵdir: i0.ɵɵDirectiveDeclaration<BaseControlValueAccessor, never, never, {}, {}, never, never, false, never>;
|
1084 | }
|
1085 |
|
1086 | /**
|
1087 | * Base class for all built-in ControlValueAccessor classes (except DefaultValueAccessor, which is
|
1088 | * used in case no other CVAs can be found). We use this class to distinguish between default CVA,
|
1089 | * built-in CVAs and custom CVAs, so that Forms logic can recognize built-in CVAs and treat custom
|
1090 | * ones with higher priority (when both built-in and custom CVAs are present).
|
1091 | *
|
1092 | * Note: this is an *internal-only* class and should not be extended or used directly in
|
1093 | * applications code.
|
1094 | */
|
1095 | declare class BuiltInControlValueAccessor extends BaseControlValueAccessor {
|
1096 | static ɵfac: i0.ɵɵFactoryDeclaration<BuiltInControlValueAccessor, never>;
|
1097 | static ɵdir: i0.ɵɵDirectiveDeclaration<BuiltInControlValueAccessor, never, never, {}, {}, never, never, false, never>;
|
1098 | }
|
1099 |
|
1100 | /**
|
1101 | * Token to provide to allow SetDisabledState to always be called when a CVA is added, regardless of
|
1102 | * whether the control is disabled or enabled.
|
1103 | *
|
1104 | * @see {@link FormsModule#withconfig}
|
1105 | */
|
1106 | declare const CALL_SET_DISABLED_STATE: InjectionToken<SetDisabledStateOption>;
|
1107 |
|
1108 | /**
|
1109 | * @description
|
1110 | * Provider which adds `CheckboxRequiredValidator` to the `NG_VALIDATORS` multi-provider list.
|
1111 | */
|
1112 | declare const CHECKBOX_REQUIRED_VALIDATOR: Provider;
|
1113 |
|
1114 | /**
|
1115 | * @description
|
1116 | * A `ControlValueAccessor` for writing a value and listening to changes on a checkbox input
|
1117 | * element.
|
1118 | *
|
1119 | * @usageNotes
|
1120 | *
|
1121 | * ### Using a checkbox with a reactive form.
|
1122 | *
|
1123 | * The following example shows how to use a checkbox with a reactive form.
|
1124 | *
|
1125 | * ```ts
|
1126 | * const rememberLoginControl = new FormControl();
|
1127 | * ```
|
1128 | *
|
1129 | * ```
|
1130 | * <input type="checkbox" [formControl]="rememberLoginControl">
|
1131 | * ```
|
1132 | *
|
1133 | * @ngModule ReactiveFormsModule
|
1134 | * @ngModule FormsModule
|
1135 | * @publicApi
|
1136 | */
|
1137 | export declare class CheckboxControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {
|
1138 | /**
|
1139 | * Sets the "checked" property on the input element.
|
1140 | * @nodoc
|
1141 | */
|
1142 | writeValue(value: any): void;
|
1143 | static ɵfac: i0.ɵɵFactoryDeclaration<CheckboxControlValueAccessor, never>;
|
1144 | static ɵdir: i0.ɵɵDirectiveDeclaration<CheckboxControlValueAccessor, "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]", never, {}, {}, never, never, false, never>;
|
1145 | }
|
1146 |
|
1147 | /**
|
1148 | * A Directive that adds the `required` validator to checkbox controls marked with the
|
1149 | * `required` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
1150 | *
|
1151 | * @see [Form Validation](guide/forms/form-validation)
|
1152 | *
|
1153 | * @usageNotes
|
1154 | *
|
1155 | * ### Adding a required checkbox validator using template-driven forms
|
1156 | *
|
1157 | * The following example shows how to add a checkbox required validator to an input attached to an
|
1158 | * ngModel binding.
|
1159 | *
|
1160 | * ```
|
1161 | * <input type="checkbox" name="active" ngModel required>
|
1162 | * ```
|
1163 | *
|
1164 | * @publicApi
|
1165 | * @ngModule FormsModule
|
1166 | * @ngModule ReactiveFormsModule
|
1167 | */
|
1168 | export declare class CheckboxRequiredValidator extends RequiredValidator {
|
1169 | static ɵfac: i0.ɵɵFactoryDeclaration<CheckboxRequiredValidator, never>;
|
1170 | static ɵdir: i0.ɵɵDirectiveDeclaration<CheckboxRequiredValidator, "input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]", never, {}, {}, never, never, false, never>;
|
1171 | }
|
1172 |
|
1173 | /**
|
1174 | * @description
|
1175 | * Provide this token to control if form directives buffer IME input until
|
1176 | * the "compositionend" event occurs.
|
1177 | * @publicApi
|
1178 | */
|
1179 | export declare const COMPOSITION_BUFFER_MODE: InjectionToken<boolean>;
|
1180 |
|
1181 | /**
|
1182 | * ControlConfig<T> is a tuple containing a value of type T, plus optional validators and async
|
1183 | * validators.
|
1184 | *
|
1185 | * @publicApi
|
1186 | */
|
1187 | export declare type ControlConfig<T> = [
|
1188 | T | FormControlState<T>,
|
1189 | (ValidatorFn | ValidatorFn[])?,
|
1190 | (AsyncValidatorFn | AsyncValidatorFn[])?
|
1191 | ];
|
1192 |
|
1193 | /**
|
1194 | * @description
|
1195 | * A base class for directives that contain multiple registered instances of `NgControl`.
|
1196 | * Only used by the forms module.
|
1197 | *
|
1198 | * @publicApi
|
1199 | */
|
1200 | export declare abstract class ControlContainer extends AbstractControlDirective {
|
1201 | /**
|
1202 | * @description
|
1203 | * The name for the control
|
1204 | */
|
1205 | name: string | number | null;
|
1206 | /**
|
1207 | * @description
|
1208 | * The top-level form directive for the control.
|
1209 | */
|
1210 | get formDirective(): Form | null;
|
1211 | /**
|
1212 | * @description
|
1213 | * The path to this group.
|
1214 | */
|
1215 | get path(): string[] | null;
|
1216 | }
|
1217 |
|
1218 | /**
|
1219 | * Base class for every event sent by `AbstractControl.events()`
|
1220 | *
|
1221 | * @publicApi
|
1222 | */
|
1223 | export declare abstract class ControlEvent<T = any> {
|
1224 | /**
|
1225 | * Form control from which this event is originated.
|
1226 | */
|
1227 | abstract readonly source: AbstractControl<unknown>;
|
1228 | }
|
1229 |
|
1230 | /**
|
1231 | * @description
|
1232 | * Defines an interface that acts as a bridge between the Angular forms API and a
|
1233 | * native element in the DOM.
|
1234 | *
|
1235 | * Implement this interface to create a custom form control directive
|
1236 | * that integrates with Angular forms.
|
1237 | *
|
1238 | * @see {@link DefaultValueAccessor}
|
1239 | *
|
1240 | * @publicApi
|
1241 | */
|
1242 | export declare interface ControlValueAccessor {
|
1243 | /**
|
1244 | * @description
|
1245 | * Writes a new value to the element.
|
1246 | *
|
1247 | * This method is called by the forms API to write to the view when programmatic
|
1248 | * changes from model to view are requested.
|
1249 | *
|
1250 | * @usageNotes
|
1251 | * ### Write a value to the element
|
1252 | *
|
1253 | * The following example writes a value to the native DOM element.
|
1254 | *
|
1255 | * ```ts
|
1256 | * writeValue(value: any): void {
|
1257 | * this._renderer.setProperty(this._elementRef.nativeElement, 'value', value);
|
1258 | * }
|
1259 | * ```
|
1260 | *
|
1261 | * @param obj The new value for the element
|
1262 | */
|
1263 | writeValue(obj: any): void;
|
1264 | /**
|
1265 | * @description
|
1266 | * Registers a callback function that is called when the control's value
|
1267 | * changes in the UI.
|
1268 | *
|
1269 | * This method is called by the forms API on initialization to update the form
|
1270 | * model when values propagate from the view to the model.
|
1271 | *
|
1272 | * When implementing the `registerOnChange` method in your own value accessor,
|
1273 | * save the given function so your class calls it at the appropriate time.
|
1274 | *
|
1275 | * @usageNotes
|
1276 | * ### Store the change function
|
1277 | *
|
1278 | * The following example stores the provided function as an internal method.
|
1279 | *
|
1280 | * ```ts
|
1281 | * registerOnChange(fn: (_: any) => void): void {
|
1282 | * this._onChange = fn;
|
1283 | * }
|
1284 | * ```
|
1285 | *
|
1286 | * When the value changes in the UI, call the registered
|
1287 | * function to allow the forms API to update itself:
|
1288 | *
|
1289 | * ```ts
|
1290 | * host: {
|
1291 | * '(change)': '_onChange($event.target.value)'
|
1292 | * }
|
1293 | * ```
|
1294 | *
|
1295 | * @param fn The callback function to register
|
1296 | */
|
1297 | registerOnChange(fn: any): void;
|
1298 | /**
|
1299 | * @description
|
1300 | * Registers a callback function that is called by the forms API on initialization
|
1301 | * to update the form model on blur.
|
1302 | *
|
1303 | * When implementing `registerOnTouched` in your own value accessor, save the given
|
1304 | * function so your class calls it when the control should be considered
|
1305 | * blurred or "touched".
|
1306 | *
|
1307 | * @usageNotes
|
1308 | * ### Store the callback function
|
1309 | *
|
1310 | * The following example stores the provided function as an internal method.
|
1311 | *
|
1312 | * ```ts
|
1313 | * registerOnTouched(fn: any): void {
|
1314 | * this._onTouched = fn;
|
1315 | * }
|
1316 | * ```
|
1317 | *
|
1318 | * On blur (or equivalent), your class should call the registered function to allow
|
1319 | * the forms API to update itself:
|
1320 | *
|
1321 | * ```ts
|
1322 | * host: {
|
1323 | * '(blur)': '_onTouched()'
|
1324 | * }
|
1325 | * ```
|
1326 | *
|
1327 | * @param fn The callback function to register
|
1328 | */
|
1329 | registerOnTouched(fn: any): void;
|
1330 | /**
|
1331 | * @description
|
1332 | * Function that is called by the forms API when the control status changes to
|
1333 | * or from 'DISABLED'. Depending on the status, it enables or disables the
|
1334 | * appropriate DOM element.
|
1335 | *
|
1336 | * @usageNotes
|
1337 | * The following is an example of writing the disabled property to a native DOM element:
|
1338 | *
|
1339 | * ```ts
|
1340 | * setDisabledState(isDisabled: boolean): void {
|
1341 | * this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
|
1342 | * }
|
1343 | * ```
|
1344 | *
|
1345 | * @param isDisabled The disabled status to set on the element
|
1346 | */
|
1347 | setDisabledState?(isDisabled: boolean): void;
|
1348 | }
|
1349 |
|
1350 | declare const DEFAULT_VALUE_ACCESSOR: Provider;
|
1351 |
|
1352 | /**
|
1353 | * The default `ControlValueAccessor` for writing a value and listening to changes on input
|
1354 | * elements. The accessor is used by the `FormControlDirective`, `FormControlName`, and
|
1355 | * `NgModel` directives.
|
1356 | *
|
1357 | *
|
1358 | * @usageNotes
|
1359 | *
|
1360 | * ### Using the default value accessor
|
1361 | *
|
1362 | * The following example shows how to use an input element that activates the default value accessor
|
1363 | * (in this case, a text field).
|
1364 | *
|
1365 | * ```ts
|
1366 | * const firstNameControl = new FormControl();
|
1367 | * ```
|
1368 | *
|
1369 | * ```
|
1370 | * <input type="text" [formControl]="firstNameControl">
|
1371 | * ```
|
1372 | *
|
1373 | * This value accessor is used by default for `<input type="text">` and `<textarea>` elements, but
|
1374 | * you could also use it for custom components that have similar behavior and do not require special
|
1375 | * processing. In order to attach the default value accessor to a custom element, add the
|
1376 | * `ngDefaultControl` attribute as shown below.
|
1377 | *
|
1378 | * ```
|
1379 | * <custom-input-component ngDefaultControl [(ngModel)]="value"></custom-input-component>
|
1380 | * ```
|
1381 | *
|
1382 | * @ngModule ReactiveFormsModule
|
1383 | * @ngModule FormsModule
|
1384 | * @publicApi
|
1385 | */
|
1386 | export declare class DefaultValueAccessor extends BaseControlValueAccessor implements ControlValueAccessor {
|
1387 | private _compositionMode;
|
1388 | /** Whether the user is creating a composition string (IME events). */
|
1389 | private _composing;
|
1390 | constructor(renderer: Renderer2, elementRef: ElementRef, _compositionMode: boolean);
|
1391 | /**
|
1392 | * Sets the "value" property on the input element.
|
1393 | * @nodoc
|
1394 | */
|
1395 | writeValue(value: any): void;
|
1396 | static ɵfac: i0.ɵɵFactoryDeclaration<DefaultValueAccessor, [null, null, { optional: true; }]>;
|
1397 | static ɵdir: i0.ɵɵDirectiveDeclaration<DefaultValueAccessor, "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]", never, {}, {}, never, never, false, never>;
|
1398 | }
|
1399 |
|
1400 | /**
|
1401 | * @description
|
1402 | * Provider which adds `EmailValidator` to the `NG_VALIDATORS` multi-provider list.
|
1403 | */
|
1404 | declare const EMAIL_VALIDATOR: any;
|
1405 |
|
1406 | /**
|
1407 | * A directive that adds the `email` validator to controls marked with the
|
1408 | * `email` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
1409 | *
|
1410 | * The email validation is based on the WHATWG HTML specification with some enhancements to
|
1411 | * incorporate more RFC rules. More information can be found on the [Validators.email
|
1412 | * page](api/forms/Validators#email).
|
1413 | *
|
1414 | * @see [Form Validation](guide/forms/form-validation)
|
1415 | *
|
1416 | * @usageNotes
|
1417 | *
|
1418 | * ### Adding an email validator
|
1419 | *
|
1420 | * The following example shows how to add an email validator to an input attached to an ngModel
|
1421 | * binding.
|
1422 | *
|
1423 | * ```
|
1424 | * <input type="email" name="email" ngModel email>
|
1425 | * <input type="email" name="email" ngModel email="true">
|
1426 | * <input type="email" name="email" ngModel [email]="true">
|
1427 | * ```
|
1428 | *
|
1429 | * @publicApi
|
1430 | * @ngModule FormsModule
|
1431 | * @ngModule ReactiveFormsModule
|
1432 | */
|
1433 | export declare class EmailValidator extends AbstractValidatorDirective {
|
1434 | /**
|
1435 | * @description
|
1436 | * Tracks changes to the email attribute bound to this directive.
|
1437 | */
|
1438 | email: boolean | string;
|
1439 | /** @nodoc */
|
1440 | enabled(input: boolean): boolean;
|
1441 | static ɵfac: i0.ɵɵFactoryDeclaration<EmailValidator, never>;
|
1442 | static ɵdir: i0.ɵɵDirectiveDeclaration<EmailValidator, "[email][formControlName],[email][formControl],[email][ngModel]", never, { "email": { "alias": "email"; "required": false; }; }, {}, never, never, false, never>;
|
1443 | }
|
1444 |
|
1445 | /**
|
1446 | * @description
|
1447 | * An interface implemented by `FormGroupDirective` and `NgForm` directives.
|
1448 | *
|
1449 | * Only used by the `ReactiveFormsModule` and `FormsModule`.
|
1450 | *
|
1451 | * @publicApi
|
1452 | */
|
1453 | export declare interface Form {
|
1454 | /**
|
1455 | * @description
|
1456 | * Add a control to this form.
|
1457 | *
|
1458 | * @param dir The control directive to add to the form.
|
1459 | */
|
1460 | addControl(dir: NgControl): void;
|
1461 | /**
|
1462 | * @description
|
1463 | * Remove a control from this form.
|
1464 | *
|
1465 | * @param dir: The control directive to remove from the form.
|
1466 | */
|
1467 | removeControl(dir: NgControl): void;
|
1468 | /**
|
1469 | * @description
|
1470 | * The control directive from which to get the `FormControl`.
|
1471 | *
|
1472 | * @param dir: The control directive.
|
1473 | */
|
1474 | getControl(dir: NgControl): FormControl;
|
1475 | /**
|
1476 | * @description
|
1477 | * Add a group of controls to this form.
|
1478 | *
|
1479 | * @param dir: The control group directive to add.
|
1480 | */
|
1481 | addFormGroup(dir: AbstractFormGroupDirective): void;
|
1482 | /**
|
1483 | * @description
|
1484 | * Remove a group of controls to this form.
|
1485 | *
|
1486 | * @param dir: The control group directive to remove.
|
1487 | */
|
1488 | removeFormGroup(dir: AbstractFormGroupDirective): void;
|
1489 | /**
|
1490 | * @description
|
1491 | * The `FormGroup` associated with a particular `AbstractFormGroupDirective`.
|
1492 | *
|
1493 | * @param dir: The form group directive from which to get the `FormGroup`.
|
1494 | */
|
1495 | getFormGroup(dir: AbstractFormGroupDirective): FormGroup;
|
1496 | /**
|
1497 | * @description
|
1498 | * Update the model for a particular control with a new value.
|
1499 | *
|
1500 | * @param dir: The control directive to update.
|
1501 | * @param value: The new value for the control.
|
1502 | */
|
1503 | updateModel(dir: NgControl, value: any): void;
|
1504 | }
|
1505 |
|
1506 | /**
|
1507 | * Tracks the value and validity state of an array of `FormControl`,
|
1508 | * `FormGroup` or `FormArray` instances.
|
1509 | *
|
1510 | * A `FormArray` aggregates the values of each child `FormControl` into an array.
|
1511 | * It calculates its status by reducing the status values of its children. For example, if one of
|
1512 | * the controls in a `FormArray` is invalid, the entire array becomes invalid.
|
1513 | *
|
1514 | * `FormArray` accepts one generic argument, which is the type of the controls inside.
|
1515 | * If you need a heterogenous array, use {@link UntypedFormArray}.
|
1516 | *
|
1517 | * `FormArray` is one of the four fundamental building blocks used to define forms in Angular,
|
1518 | * along with `FormControl`, `FormGroup`, and `FormRecord`.
|
1519 | *
|
1520 | * @usageNotes
|
1521 | *
|
1522 | * ### Create an array of form controls
|
1523 | *
|
1524 | * ```
|
1525 | * const arr = new FormArray([
|
1526 | * new FormControl('Nancy', Validators.minLength(2)),
|
1527 | * new FormControl('Drew'),
|
1528 | * ]);
|
1529 | *
|
1530 | * console.log(arr.value); // ['Nancy', 'Drew']
|
1531 | * console.log(arr.status); // 'VALID'
|
1532 | * ```
|
1533 | *
|
1534 | * ### Create a form array with array-level validators
|
1535 | *
|
1536 | * You include array-level validators and async validators. These come in handy
|
1537 | * when you want to perform validation that considers the value of more than one child
|
1538 | * control.
|
1539 | *
|
1540 | * The two types of validators are passed in separately as the second and third arg
|
1541 | * respectively, or together as part of an options object.
|
1542 | *
|
1543 | * ```
|
1544 | * const arr = new FormArray([
|
1545 | * new FormControl('Nancy'),
|
1546 | * new FormControl('Drew')
|
1547 | * ], {validators: myValidator, asyncValidators: myAsyncValidator});
|
1548 | * ```
|
1549 | *
|
1550 | * ### Set the updateOn property for all controls in a form array
|
1551 | *
|
1552 | * The options object is used to set a default value for each child
|
1553 | * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
|
1554 | * array level, all child controls default to 'blur', unless the child
|
1555 | * has explicitly specified a different `updateOn` value.
|
1556 | *
|
1557 | * ```ts
|
1558 | * const arr = new FormArray([
|
1559 | * new FormControl()
|
1560 | * ], {updateOn: 'blur'});
|
1561 | * ```
|
1562 | *
|
1563 | * ### Adding or removing controls from a form array
|
1564 | *
|
1565 | * To change the controls in the array, use the `push`, `insert`, `removeAt` or `clear` methods
|
1566 | * in `FormArray` itself. These methods ensure the controls are properly tracked in the
|
1567 | * form's hierarchy. Do not modify the array of `AbstractControl`s used to instantiate
|
1568 | * the `FormArray` directly, as that result in strange and unexpected behavior such
|
1569 | * as broken change detection.
|
1570 | *
|
1571 | * @publicApi
|
1572 | */
|
1573 | export declare class FormArray<TControl extends AbstractControl<any> = any> extends AbstractControl<ɵTypedOrUntyped<TControl, ɵFormArrayValue<TControl>, any>, ɵTypedOrUntyped<TControl, ɵFormArrayRawValue<TControl>, any>> {
|
1574 | /**
|
1575 | * Creates a new `FormArray` instance.
|
1576 | *
|
1577 | * @param controls An array of child controls. Each child control is given an index
|
1578 | * where it is registered.
|
1579 | *
|
1580 | * @param validatorOrOpts A synchronous validator function, or an array of
|
1581 | * such functions, or an `AbstractControlOptions` object that contains validation functions
|
1582 | * and a validation trigger.
|
1583 | *
|
1584 | * @param asyncValidator A single async validator or array of async validator functions
|
1585 | *
|
1586 | */
|
1587 | constructor(controls: Array<TControl>, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
|
1588 | controls: ɵTypedOrUntyped<TControl, Array<TControl>, Array<AbstractControl<any>>>;
|
1589 | /**
|
1590 | * Get the `AbstractControl` at the given `index` in the array.
|
1591 | *
|
1592 | * @param index Index in the array to retrieve the control. If `index` is negative, it will wrap
|
1593 | * around from the back, and if index is greatly negative (less than `-length`), the result is
|
1594 | * undefined. This behavior is the same as `Array.at(index)`.
|
1595 | */
|
1596 | at(index: number): ɵTypedOrUntyped<TControl, TControl, AbstractControl<any>>;
|
1597 | /**
|
1598 | * Insert a new `AbstractControl` at the end of the array.
|
1599 | *
|
1600 | * @param control Form control to be inserted
|
1601 | * @param options Specifies whether this FormArray instance should emit events after a new
|
1602 | * control is added.
|
1603 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1604 | * `valueChanges` observables emit events with the latest status and value when the control is
|
1605 | * inserted. When false, no events are emitted.
|
1606 | */
|
1607 | push(control: TControl, options?: {
|
1608 | emitEvent?: boolean;
|
1609 | }): void;
|
1610 | /**
|
1611 | * Insert a new `AbstractControl` at the given `index` in the array.
|
1612 | *
|
1613 | * @param index Index in the array to insert the control. If `index` is negative, wraps around
|
1614 | * from the back. If `index` is greatly negative (less than `-length`), prepends to the array.
|
1615 | * This behavior is the same as `Array.splice(index, 0, control)`.
|
1616 | * @param control Form control to be inserted
|
1617 | * @param options Specifies whether this FormArray instance should emit events after a new
|
1618 | * control is inserted.
|
1619 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1620 | * `valueChanges` observables emit events with the latest status and value when the control is
|
1621 | * inserted. When false, no events are emitted.
|
1622 | */
|
1623 | insert(index: number, control: TControl, options?: {
|
1624 | emitEvent?: boolean;
|
1625 | }): void;
|
1626 | /**
|
1627 | * Remove the control at the given `index` in the array.
|
1628 | *
|
1629 | * @param index Index in the array to remove the control. If `index` is negative, wraps around
|
1630 | * from the back. If `index` is greatly negative (less than `-length`), removes the first
|
1631 | * element. This behavior is the same as `Array.splice(index, 1)`.
|
1632 | * @param options Specifies whether this FormArray instance should emit events after a
|
1633 | * control is removed.
|
1634 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1635 | * `valueChanges` observables emit events with the latest status and value when the control is
|
1636 | * removed. When false, no events are emitted.
|
1637 | */
|
1638 | removeAt(index: number, options?: {
|
1639 | emitEvent?: boolean;
|
1640 | }): void;
|
1641 | /**
|
1642 | * Replace an existing control.
|
1643 | *
|
1644 | * @param index Index in the array to replace the control. If `index` is negative, wraps around
|
1645 | * from the back. If `index` is greatly negative (less than `-length`), replaces the first
|
1646 | * element. This behavior is the same as `Array.splice(index, 1, control)`.
|
1647 | * @param control The `AbstractControl` control to replace the existing control
|
1648 | * @param options Specifies whether this FormArray instance should emit events after an
|
1649 | * existing control is replaced with a new one.
|
1650 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1651 | * `valueChanges` observables emit events with the latest status and value when the control is
|
1652 | * replaced with a new one. When false, no events are emitted.
|
1653 | */
|
1654 | setControl(index: number, control: TControl, options?: {
|
1655 | emitEvent?: boolean;
|
1656 | }): void;
|
1657 | /**
|
1658 | * Length of the control array.
|
1659 | */
|
1660 | get length(): number;
|
1661 | /**
|
1662 | * Sets the value of the `FormArray`. It accepts an array that matches
|
1663 | * the structure of the control.
|
1664 | *
|
1665 | * This method performs strict checks, and throws an error if you try
|
1666 | * to set the value of a control that doesn't exist or if you exclude the
|
1667 | * value of a control.
|
1668 | *
|
1669 | * @usageNotes
|
1670 | * ### Set the values for the controls in the form array
|
1671 | *
|
1672 | * ```
|
1673 | * const arr = new FormArray([
|
1674 | * new FormControl(),
|
1675 | * new FormControl()
|
1676 | * ]);
|
1677 | * console.log(arr.value); // [null, null]
|
1678 | *
|
1679 | * arr.setValue(['Nancy', 'Drew']);
|
1680 | * console.log(arr.value); // ['Nancy', 'Drew']
|
1681 | * ```
|
1682 | *
|
1683 | * @param value Array of values for the controls
|
1684 | * @param options Configure options that determine how the control propagates changes and
|
1685 | * emits events after the value changes
|
1686 | *
|
1687 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default
|
1688 | * is false.
|
1689 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1690 | * `valueChanges`
|
1691 | * observables emit events with the latest status and value when the control value is updated.
|
1692 | * When false, no events are emitted.
|
1693 | * The configuration options are passed to the { AbstractControl#updateValueAndValidity
|
1694 | * updateValueAndValidity} method.
|
1695 | */
|
1696 | setValue(value: ɵFormArrayRawValue<TControl>, options?: {
|
1697 | onlySelf?: boolean;
|
1698 | emitEvent?: boolean;
|
1699 | }): void;
|
1700 | /**
|
1701 | * Patches the value of the `FormArray`. It accepts an array that matches the
|
1702 | * structure of the control, and does its best to match the values to the correct
|
1703 | * controls in the group.
|
1704 | *
|
1705 | * It accepts both super-sets and sub-sets of the array without throwing an error.
|
1706 | *
|
1707 | * @usageNotes
|
1708 | * ### Patch the values for controls in a form array
|
1709 | *
|
1710 | * ```
|
1711 | * const arr = new FormArray([
|
1712 | * new FormControl(),
|
1713 | * new FormControl()
|
1714 | * ]);
|
1715 | * console.log(arr.value); // [null, null]
|
1716 | *
|
1717 | * arr.patchValue(['Nancy']);
|
1718 | * console.log(arr.value); // ['Nancy', null]
|
1719 | * ```
|
1720 | *
|
1721 | * @param value Array of latest values for the controls
|
1722 | * @param options Configure options that determine how the control propagates changes and
|
1723 | * emits events after the value changes
|
1724 | *
|
1725 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default
|
1726 | * is false.
|
1727 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1728 | * `valueChanges` observables emit events with the latest status and value when the control
|
1729 | * value is updated. When false, no events are emitted. The configuration options are passed to
|
1730 | * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method.
|
1731 | */
|
1732 | patchValue(value: ɵFormArrayValue<TControl>, options?: {
|
1733 | onlySelf?: boolean;
|
1734 | emitEvent?: boolean;
|
1735 | }): void;
|
1736 | /**
|
1737 | * Resets the `FormArray` and all descendants are marked `pristine` and `untouched`, and the
|
1738 | * value of all descendants to null or null maps.
|
1739 | *
|
1740 | * You reset to a specific form state by passing in an array of states
|
1741 | * that matches the structure of the control. The state is a standalone value
|
1742 | * or a form state object with both a value and a disabled status.
|
1743 | *
|
1744 | * @usageNotes
|
1745 | * ### Reset the values in a form array
|
1746 | *
|
1747 | * ```ts
|
1748 | * const arr = new FormArray([
|
1749 | * new FormControl(),
|
1750 | * new FormControl()
|
1751 | * ]);
|
1752 | * arr.reset(['name', 'last name']);
|
1753 | *
|
1754 | * console.log(arr.value); // ['name', 'last name']
|
1755 | * ```
|
1756 | *
|
1757 | * ### Reset the values in a form array and the disabled status for the first control
|
1758 | *
|
1759 | * ```
|
1760 | * arr.reset([
|
1761 | * {value: 'name', disabled: true},
|
1762 | * 'last'
|
1763 | * ]);
|
1764 | *
|
1765 | * console.log(arr.value); // ['last']
|
1766 | * console.log(arr.at(0).status); // 'DISABLED'
|
1767 | * ```
|
1768 | *
|
1769 | * @param value Array of values for the controls
|
1770 | * @param options Configure options that determine how the control propagates changes and
|
1771 | * emits events after the value changes
|
1772 | *
|
1773 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default
|
1774 | * is false.
|
1775 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1776 | * `valueChanges`
|
1777 | * observables emit events with the latest status and value when the control is reset.
|
1778 | * When false, no events are emitted.
|
1779 | * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
|
1780 | * updateValueAndValidity} method.
|
1781 | */
|
1782 | reset(value?: ɵTypedOrUntyped<TControl, ɵFormArrayValue<TControl>, any>, options?: {
|
1783 | onlySelf?: boolean;
|
1784 | emitEvent?: boolean;
|
1785 | }): void;
|
1786 | /**
|
1787 | * The aggregate value of the array, including any disabled controls.
|
1788 | *
|
1789 | * Reports all values regardless of disabled status.
|
1790 | */
|
1791 | getRawValue(): ɵFormArrayRawValue<TControl>;
|
1792 | /**
|
1793 | * Remove all controls in the `FormArray`.
|
1794 | *
|
1795 | * @param options Specifies whether this FormArray instance should emit events after all
|
1796 | * controls are removed.
|
1797 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
1798 | * `valueChanges` observables emit events with the latest status and value when all controls
|
1799 | * in this FormArray instance are removed. When false, no events are emitted.
|
1800 | *
|
1801 | * @usageNotes
|
1802 | * ### Remove all elements from a FormArray
|
1803 | *
|
1804 | * ```ts
|
1805 | * const arr = new FormArray([
|
1806 | * new FormControl(),
|
1807 | * new FormControl()
|
1808 | * ]);
|
1809 | * console.log(arr.length); // 2
|
1810 | *
|
1811 | * arr.clear();
|
1812 | * console.log(arr.length); // 0
|
1813 | * ```
|
1814 | *
|
1815 | * It's a simpler and more efficient alternative to removing all elements one by one:
|
1816 | *
|
1817 | * ```ts
|
1818 | * const arr = new FormArray([
|
1819 | * new FormControl(),
|
1820 | * new FormControl()
|
1821 | * ]);
|
1822 | *
|
1823 | * while (arr.length) {
|
1824 | * arr.removeAt(0);
|
1825 | * }
|
1826 | * ```
|
1827 | */
|
1828 | clear(options?: {
|
1829 | emitEvent?: boolean;
|
1830 | }): void;
|
1831 | private _registerControl;
|
1832 | }
|
1833 |
|
1834 | /**
|
1835 | * @description
|
1836 | *
|
1837 | * Syncs a nested `FormArray` to a DOM element.
|
1838 | *
|
1839 | * This directive is designed to be used with a parent `FormGroupDirective` (selector:
|
1840 | * `[formGroup]`).
|
1841 | *
|
1842 | * It accepts the string name of the nested `FormArray` you want to link, and
|
1843 | * will look for a `FormArray` registered with that name in the parent
|
1844 | * `FormGroup` instance you passed into `FormGroupDirective`.
|
1845 | *
|
1846 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
1847 | * @see {@link AbstractControl}
|
1848 | *
|
1849 | * @usageNotes
|
1850 | *
|
1851 | * ### Example
|
1852 | *
|
1853 | * {@example forms/ts/nestedFormArray/nested_form_array_example.ts region='Component'}
|
1854 | *
|
1855 | * @ngModule ReactiveFormsModule
|
1856 | * @publicApi
|
1857 | */
|
1858 | export declare class FormArrayName extends ControlContainer implements OnInit, OnDestroy {
|
1859 | /**
|
1860 | * @description
|
1861 | * Tracks the name of the `FormArray` bound to the directive. The name corresponds
|
1862 | * to a key in the parent `FormGroup` or `FormArray`.
|
1863 | * Accepts a name as a string or a number.
|
1864 | * The name in the form of a string is useful for individual forms,
|
1865 | * while the numerical form allows for form arrays to be bound
|
1866 | * to indices when iterating over arrays in a `FormArray`.
|
1867 | */
|
1868 | name: string | number | null;
|
1869 | constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[]);
|
1870 | /**
|
1871 | * A lifecycle method called when the directive's inputs are initialized. For internal use only.
|
1872 | * @throws If the directive does not have a valid parent.
|
1873 | * @nodoc
|
1874 | */
|
1875 | ngOnInit(): void;
|
1876 | /**
|
1877 | * A lifecycle method called before the directive's instance is destroyed. For internal use only.
|
1878 | * @nodoc
|
1879 | */
|
1880 | ngOnDestroy(): void;
|
1881 | /**
|
1882 | * @description
|
1883 | * The `FormArray` bound to this directive.
|
1884 | */
|
1885 | get control(): FormArray;
|
1886 | /**
|
1887 | * @description
|
1888 | * The top-level directive for this group if present, otherwise null.
|
1889 | */
|
1890 | get formDirective(): FormGroupDirective | null;
|
1891 | /**
|
1892 | * @description
|
1893 | * Returns an array that represents the path from the top-level form to this control.
|
1894 | * Each index is the string name of the control on that level.
|
1895 | */
|
1896 | get path(): string[];
|
1897 | private _checkParentType;
|
1898 | static ɵfac: i0.ɵɵFactoryDeclaration<FormArrayName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>;
|
1899 | static ɵdir: i0.ɵɵDirectiveDeclaration<FormArrayName, "[formArrayName]", never, { "name": { "alias": "formArrayName"; "required": false; }; }, {}, never, never, false, never>;
|
1900 | }
|
1901 |
|
1902 | declare const formArrayNameProvider: any;
|
1903 |
|
1904 | /**
|
1905 | * @description
|
1906 | * Creates an `AbstractControl` from a user-specified configuration.
|
1907 | *
|
1908 | * The `FormBuilder` provides syntactic sugar that shortens creating instances of a
|
1909 | * `FormControl`, `FormGroup`, or `FormArray`. It reduces the amount of boilerplate needed to
|
1910 | * build complex forms.
|
1911 | *
|
1912 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
1913 | *
|
1914 | * @publicApi
|
1915 | */
|
1916 | export declare class FormBuilder {
|
1917 | private useNonNullable;
|
1918 | /**
|
1919 | * @description
|
1920 | * Returns a FormBuilder in which automatically constructed `FormControl` elements
|
1921 | * have `{nonNullable: true}` and are non-nullable.
|
1922 | *
|
1923 | * **Constructing non-nullable controls**
|
1924 | *
|
1925 | * When constructing a control, it will be non-nullable, and will reset to its initial value.
|
1926 | *
|
1927 | * ```ts
|
1928 | * let nnfb = new FormBuilder().nonNullable;
|
1929 | * let name = nnfb.control('Alex'); // FormControl<string>
|
1930 | * name.reset();
|
1931 | * console.log(name); // 'Alex'
|
1932 | * ```
|
1933 | *
|
1934 | * **Constructing non-nullable groups or arrays**
|
1935 | *
|
1936 | * When constructing a group or array, all automatically created inner controls will be
|
1937 | * non-nullable, and will reset to their initial values.
|
1938 | *
|
1939 | * ```ts
|
1940 | * let nnfb = new FormBuilder().nonNullable;
|
1941 | * let name = nnfb.group({who: 'Alex'}); // FormGroup<{who: FormControl<string>}>
|
1942 | * name.reset();
|
1943 | * console.log(name); // {who: 'Alex'}
|
1944 | * ```
|
1945 | * **Constructing *nullable* fields on groups or arrays**
|
1946 | *
|
1947 | * It is still possible to have a nullable field. In particular, any `FormControl` which is
|
1948 | * *already* constructed will not be altered. For example:
|
1949 | *
|
1950 | * ```ts
|
1951 | * let nnfb = new FormBuilder().nonNullable;
|
1952 | * // FormGroup<{who: FormControl<string|null>}>
|
1953 | * let name = nnfb.group({who: new FormControl('Alex')});
|
1954 | * name.reset(); console.log(name); // {who: null}
|
1955 | * ```
|
1956 | *
|
1957 | * Because the inner control is constructed explicitly by the caller, the builder has
|
1958 | * no control over how it is created, and cannot exclude the `null`.
|
1959 | */
|
1960 | get nonNullable(): NonNullableFormBuilder;
|
1961 | /**
|
1962 | * @description
|
1963 | * Constructs a new `FormGroup` instance. Accepts a single generic argument, which is an object
|
1964 | * containing all the keys and corresponding inner control types.
|
1965 | *
|
1966 | * @param controls A collection of child controls. The key for each child is the name
|
1967 | * under which it is registered.
|
1968 | *
|
1969 | * @param options Configuration options object for the `FormGroup`. The object should have the
|
1970 | * `AbstractControlOptions` type and might contain the following fields:
|
1971 | * * `validators`: A synchronous validator function, or an array of validator functions.
|
1972 | * * `asyncValidators`: A single async validator or array of async validator functions.
|
1973 | * * `updateOn`: The event upon which the control should be updated (options: 'change' | 'blur'
|
1974 | * | submit').
|
1975 | */
|
1976 | group<T extends {}>(controls: T, options?: AbstractControlOptions | null): FormGroup<{
|
1977 | [K in keyof T]: ɵElement<T[K], null>;
|
1978 | }>;
|
1979 | /**
|
1980 | * @description
|
1981 | * Constructs a new `FormGroup` instance.
|
1982 | *
|
1983 | * @deprecated This API is not typesafe and can result in issues with Closure Compiler renaming.
|
1984 | * Use the `FormBuilder#group` overload with `AbstractControlOptions` instead.
|
1985 | * Note that `AbstractControlOptions` expects `validators` and `asyncValidators` to be valid
|
1986 | * validators. If you have custom validators, make sure their validation function parameter is
|
1987 | * `AbstractControl` and not a sub-class, such as `FormGroup`. These functions will be called
|
1988 | * with an object of type `AbstractControl` and that cannot be automatically downcast to a
|
1989 | * subclass, so TypeScript sees this as an error. For example, change the `(group: FormGroup) =>
|
1990 | * ValidationErrors|null` signature to be `(group: AbstractControl) => ValidationErrors|null`.
|
1991 | *
|
1992 | * @param controls A record of child controls. The key for each child is the name
|
1993 | * under which the control is registered.
|
1994 | *
|
1995 | * @param options Configuration options object for the `FormGroup`. The legacy configuration
|
1996 | * object consists of:
|
1997 | * * `validator`: A synchronous validator function, or an array of validator functions.
|
1998 | * * `asyncValidator`: A single async validator or array of async validator functions
|
1999 | * Note: the legacy format is deprecated and might be removed in one of the next major versions
|
2000 | * of Angular.
|
2001 | */
|
2002 | group(controls: {
|
2003 | [key: string]: any;
|
2004 | }, options: {
|
2005 | [key: string]: any;
|
2006 | }): FormGroup;
|
2007 | /**
|
2008 | * @description
|
2009 | * Constructs a new `FormRecord` instance. Accepts a single generic argument, which is an object
|
2010 | * containing all the keys and corresponding inner control types.
|
2011 | *
|
2012 | * @param controls A collection of child controls. The key for each child is the name
|
2013 | * under which it is registered.
|
2014 | *
|
2015 | * @param options Configuration options object for the `FormRecord`. The object should have the
|
2016 | * `AbstractControlOptions` type and might contain the following fields:
|
2017 | * * `validators`: A synchronous validator function, or an array of validator functions.
|
2018 | * * `asyncValidators`: A single async validator or array of async validator functions.
|
2019 | * * `updateOn`: The event upon which the control should be updated (options: 'change' | 'blur'
|
2020 | * | submit').
|
2021 | */
|
2022 | record<T>(controls: {
|
2023 | [key: string]: T;
|
2024 | }, options?: AbstractControlOptions | null): FormRecord<ɵElement<T, null>>;
|
2025 | /** @deprecated Use `nonNullable` instead. */
|
2026 | control<T>(formState: T | FormControlState<T>, opts: FormControlOptions & {
|
2027 | initialValueIsDefault: true;
|
2028 | }): FormControl<T>;
|
2029 | control<T>(formState: T | FormControlState<T>, opts: FormControlOptions & {
|
2030 | nonNullable: true;
|
2031 | }): FormControl<T>;
|
2032 | /**
|
2033 | * @deprecated When passing an `options` argument, the `asyncValidator` argument has no effect.
|
2034 | */
|
2035 | control<T>(formState: T | FormControlState<T>, opts: FormControlOptions, asyncValidator: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T | null>;
|
2036 | control<T>(formState: T | FormControlState<T>, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl<T | null>;
|
2037 | /**
|
2038 | * Constructs a new `FormArray` from the given array of configurations,
|
2039 | * validators and options. Accepts a single generic argument, which is the type of each control
|
2040 | * inside the array.
|
2041 | *
|
2042 | * @param controls An array of child controls or control configs. Each child control is given an
|
2043 | * index when it is registered.
|
2044 | *
|
2045 | * @param validatorOrOpts A synchronous validator function, or an array of such functions, or an
|
2046 | * `AbstractControlOptions` object that contains
|
2047 | * validation functions and a validation trigger.
|
2048 | *
|
2049 | * @param asyncValidator A single async validator or array of async validator functions.
|
2050 | */
|
2051 | array<T>(controls: Array<T>, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormArray<ɵElement<T, null>>;
|
2052 | static ɵfac: i0.ɵɵFactoryDeclaration<FormBuilder, never>;
|
2053 | static ɵprov: i0.ɵɵInjectableDeclaration<FormBuilder>;
|
2054 | }
|
2055 |
|
2056 | /**
|
2057 | * Tracks the value and validation status of an individual form control.
|
2058 | *
|
2059 | * This is one of the four fundamental building blocks of Angular forms, along with
|
2060 | * `FormGroup`, `FormArray` and `FormRecord`. It extends the `AbstractControl` class that
|
2061 | * implements most of the base functionality for accessing the value, validation status,
|
2062 | * user interactions and events.
|
2063 | *
|
2064 | * `FormControl` takes a single generic argument, which describes the type of its value. This
|
2065 | * argument always implicitly includes `null` because the control can be reset. To change this
|
2066 | * behavior, set `nonNullable` or see the usage notes below.
|
2067 | *
|
2068 | * See [usage examples below](#usage-notes).
|
2069 | *
|
2070 | * @see {@link AbstractControl}
|
2071 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
2072 | * @see [Usage Notes](#usage-notes)
|
2073 | *
|
2074 | * @publicApi
|
2075 | *
|
2076 | * @overriddenImplementation ɵFormControlCtor
|
2077 | *
|
2078 | * @usageNotes
|
2079 | *
|
2080 | * ### Initializing Form Controls
|
2081 | *
|
2082 | * Instantiate a `FormControl`, with an initial value.
|
2083 | *
|
2084 | * ```ts
|
2085 | * const control = new FormControl('some value');
|
2086 | * console.log(control.value); // 'some value'
|
2087 | * ```
|
2088 | *
|
2089 | * The following example initializes the control with a form state object. The `value`
|
2090 | * and `disabled` keys are required in this case.
|
2091 | *
|
2092 | * ```ts
|
2093 | * const control = new FormControl({ value: 'n/a', disabled: true });
|
2094 | * console.log(control.value); // 'n/a'
|
2095 | * console.log(control.status); // 'DISABLED'
|
2096 | * ```
|
2097 | *
|
2098 | * The following example initializes the control with a synchronous validator.
|
2099 | *
|
2100 | * ```ts
|
2101 | * const control = new FormControl('', Validators.required);
|
2102 | * console.log(control.value); // ''
|
2103 | * console.log(control.status); // 'INVALID'
|
2104 | * ```
|
2105 | *
|
2106 | * The following example initializes the control using an options object.
|
2107 | *
|
2108 | * ```ts
|
2109 | * const control = new FormControl('', {
|
2110 | * validators: Validators.required,
|
2111 | * asyncValidators: myAsyncValidator
|
2112 | * });
|
2113 | * ```
|
2114 | *
|
2115 | * ### The single type argument
|
2116 | *
|
2117 | * `FormControl` accepts a generic argument, which describes the type of its value.
|
2118 | * In most cases, this argument will be inferred.
|
2119 | *
|
2120 | * If you are initializing the control to `null`, or you otherwise wish to provide a
|
2121 | * wider type, you may specify the argument explicitly:
|
2122 | *
|
2123 | * ```
|
2124 | * let fc = new FormControl<string|null>(null);
|
2125 | * fc.setValue('foo');
|
2126 | * ```
|
2127 | *
|
2128 | * You might notice that `null` is always added to the type of the control.
|
2129 | * This is because the control will become `null` if you call `reset`. You can change
|
2130 | * this behavior by setting `{nonNullable: true}`.
|
2131 | *
|
2132 | * ### Configure the control to update on a blur event
|
2133 | *
|
2134 | * Set the `updateOn` option to `'blur'` to update on the blur `event`.
|
2135 | *
|
2136 | * ```ts
|
2137 | * const control = new FormControl('', { updateOn: 'blur' });
|
2138 | * ```
|
2139 | *
|
2140 | * ### Configure the control to update on a submit event
|
2141 | *
|
2142 | * Set the `updateOn` option to `'submit'` to update on a submit `event`.
|
2143 | *
|
2144 | * ```ts
|
2145 | * const control = new FormControl('', { updateOn: 'submit' });
|
2146 | * ```
|
2147 | *
|
2148 | * ### Reset the control back to a specific value
|
2149 | *
|
2150 | * You reset to a specific form state by passing through a standalone
|
2151 | * value or a form state object that contains both a value and a disabled state
|
2152 | * (these are the only two properties that cannot be calculated).
|
2153 | *
|
2154 | * ```ts
|
2155 | * const control = new FormControl('Nancy');
|
2156 | *
|
2157 | * console.log(control.value); // 'Nancy'
|
2158 | *
|
2159 | * control.reset('Drew');
|
2160 | *
|
2161 | * console.log(control.value); // 'Drew'
|
2162 | * ```
|
2163 | *
|
2164 | * ### Reset the control to its initial value
|
2165 | *
|
2166 | * If you wish to always reset the control to its initial value (instead of null),
|
2167 | * you can pass the `nonNullable` option:
|
2168 | *
|
2169 | * ```
|
2170 | * const control = new FormControl('Nancy', {nonNullable: true});
|
2171 | *
|
2172 | * console.log(control.value); // 'Nancy'
|
2173 | *
|
2174 | * control.reset();
|
2175 | *
|
2176 | * console.log(control.value); // 'Nancy'
|
2177 | * ```
|
2178 | *
|
2179 | * ### Reset the control back to an initial value and disabled
|
2180 | *
|
2181 | * ```
|
2182 | * const control = new FormControl('Nancy');
|
2183 | *
|
2184 | * console.log(control.value); // 'Nancy'
|
2185 | * console.log(control.status); // 'VALID'
|
2186 | *
|
2187 | * control.reset({ value: 'Drew', disabled: true });
|
2188 | *
|
2189 | * console.log(control.value); // 'Drew'
|
2190 | * console.log(control.status); // 'DISABLED'
|
2191 | * ```
|
2192 | */
|
2193 | export declare interface FormControl<TValue = any> extends AbstractControl<TValue> {
|
2194 | /**
|
2195 | * The default value of this FormControl, used whenever the control is reset without an explicit
|
2196 | * value. See {@link FormControlOptions#nonNullable} for more information on configuring
|
2197 | * a default value.
|
2198 | */
|
2199 | readonly defaultValue: TValue;
|
2200 | /**
|
2201 | * Sets a new value for the form control.
|
2202 | *
|
2203 | * @param value The new value for the control.
|
2204 | * @param options Configuration options that determine how the control propagates changes
|
2205 | * and emits events when the value changes.
|
2206 | * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
|
2207 | * updateValueAndValidity} method.
|
2208 | *
|
2209 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
|
2210 | * false.
|
2211 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2212 | * `valueChanges`
|
2213 | * observables emit events with the latest status and value when the control value is updated.
|
2214 | * When false, no events are emitted.
|
2215 | * * `emitModelToViewChange`: When true or not supplied (the default), each change triggers an
|
2216 | * `onChange` event to
|
2217 | * update the view.
|
2218 | * * `emitViewToModelChange`: When true or not supplied (the default), each change triggers an
|
2219 | * `ngModelChange`
|
2220 | * event to update the model.
|
2221 | *
|
2222 | */
|
2223 | setValue(value: TValue, options?: {
|
2224 | onlySelf?: boolean;
|
2225 | emitEvent?: boolean;
|
2226 | emitModelToViewChange?: boolean;
|
2227 | emitViewToModelChange?: boolean;
|
2228 | }): void;
|
2229 | /**
|
2230 | * Patches the value of a control.
|
2231 | *
|
2232 | * This function is functionally the same as {@link FormControl#setValue setValue} at this level.
|
2233 | * It exists for symmetry with {@link FormGroup#patchValue patchValue} on `FormGroups` and
|
2234 | * `FormArrays`, where it does behave differently.
|
2235 | *
|
2236 | * @see {@link FormControl#setValue} for options
|
2237 | */
|
2238 | patchValue(value: TValue, options?: {
|
2239 | onlySelf?: boolean;
|
2240 | emitEvent?: boolean;
|
2241 | emitModelToViewChange?: boolean;
|
2242 | emitViewToModelChange?: boolean;
|
2243 | }): void;
|
2244 | /**
|
2245 | * Resets the form control, marking it `pristine` and `untouched`, and resetting
|
2246 | * the value. The new value will be the provided value (if passed), `null`, or the initial value
|
2247 | * if `nonNullable` was set in the constructor via {@link FormControlOptions}.
|
2248 | *
|
2249 | * ```ts
|
2250 | * // By default, the control will reset to null.
|
2251 | * const dog = new FormControl('spot');
|
2252 | * dog.reset(); // dog.value is null
|
2253 | *
|
2254 | * // If this flag is set, the control will instead reset to the initial value.
|
2255 | * const cat = new FormControl('tabby', {nonNullable: true});
|
2256 | * cat.reset(); // cat.value is "tabby"
|
2257 | *
|
2258 | * // A value passed to reset always takes precedence.
|
2259 | * const fish = new FormControl('finn', {nonNullable: true});
|
2260 | * fish.reset('bubble'); // fish.value is "bubble"
|
2261 | * ```
|
2262 | *
|
2263 | * @param formState Resets the control with an initial value,
|
2264 | * or an object that defines the initial value and disabled state.
|
2265 | *
|
2266 | * @param options Configuration options that determine how the control propagates changes
|
2267 | * and emits events after the value changes.
|
2268 | *
|
2269 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
|
2270 | * false.
|
2271 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2272 | * `valueChanges`
|
2273 | * observables emit events with the latest status and value when the control is reset.
|
2274 | * When false, no events are emitted.
|
2275 | *
|
2276 | */
|
2277 | reset(formState?: TValue | FormControlState<TValue>, options?: {
|
2278 | onlySelf?: boolean;
|
2279 | emitEvent?: boolean;
|
2280 | }): void;
|
2281 | /**
|
2282 | * For a simple FormControl, the raw value is equivalent to the value.
|
2283 | */
|
2284 | getRawValue(): TValue;
|
2285 | /**
|
2286 | * Register a listener for change events.
|
2287 | *
|
2288 | * @param fn The method that is called when the value changes
|
2289 | */
|
2290 | registerOnChange(fn: Function): void;
|
2291 | /**
|
2292 | * Register a listener for disabled events.
|
2293 | *
|
2294 | * @param fn The method that is called when the disabled status changes.
|
2295 | */
|
2296 | registerOnDisabledChange(fn: (isDisabled: boolean) => void): void;
|
2297 | }
|
2298 |
|
2299 | export declare const FormControl: ɵFormControlCtor;
|
2300 |
|
2301 | /**
|
2302 | * @description
|
2303 | * Synchronizes a standalone `FormControl` instance to a form control element.
|
2304 | *
|
2305 | * Note that support for using the `ngModel` input property and `ngModelChange` event with reactive
|
2306 | * form directives was deprecated in Angular v6 and is scheduled for removal in
|
2307 | * a future version of Angular.
|
2308 | *
|
2309 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
2310 | * @see {@link FormControl}
|
2311 | * @see {@link AbstractControl}
|
2312 | *
|
2313 | * @usageNotes
|
2314 | *
|
2315 | * The following example shows how to register a standalone control and set its value.
|
2316 | *
|
2317 | * {@example forms/ts/simpleFormControl/simple_form_control_example.ts region='Component'}
|
2318 | *
|
2319 | * @ngModule ReactiveFormsModule
|
2320 | * @publicApi
|
2321 | */
|
2322 | export declare class FormControlDirective extends NgControl implements OnChanges, OnDestroy {
|
2323 | private _ngModelWarningConfig;
|
2324 | private callSetDisabledState?;
|
2325 | /**
|
2326 | * Internal reference to the view model value.
|
2327 | * @nodoc
|
2328 | */
|
2329 | viewModel: any;
|
2330 | /**
|
2331 | * @description
|
2332 | * Tracks the `FormControl` instance bound to the directive.
|
2333 | */
|
2334 | form: FormControl;
|
2335 | /**
|
2336 | * @description
|
2337 | * Triggers a warning in dev mode that this input should not be used with reactive forms.
|
2338 | */
|
2339 | set isDisabled(isDisabled: boolean);
|
2340 | /** @deprecated as of v6 */
|
2341 | model: any;
|
2342 | /** @deprecated as of v6 */
|
2343 | update: EventEmitter<any>;
|
2344 | constructor(validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], valueAccessors: ControlValueAccessor[], _ngModelWarningConfig: string | null, callSetDisabledState?: SetDisabledStateOption | undefined);
|
2345 | /** @nodoc */
|
2346 | ngOnChanges(changes: SimpleChanges): void;
|
2347 | /** @nodoc */
|
2348 | ngOnDestroy(): void;
|
2349 | /**
|
2350 | * @description
|
2351 | * Returns an array that represents the path from the top-level form to this control.
|
2352 | * Each index is the string name of the control on that level.
|
2353 | */
|
2354 | get path(): string[];
|
2355 | /**
|
2356 | * @description
|
2357 | * The `FormControl` bound to this directive.
|
2358 | */
|
2359 | get control(): FormControl;
|
2360 | /**
|
2361 | * @description
|
2362 | * Sets the new value for the view model and emits an `ngModelChange` event.
|
2363 | *
|
2364 | * @param newValue The new value for the view model.
|
2365 | */
|
2366 | viewToModelUpdate(newValue: any): void;
|
2367 | private _isControlChanged;
|
2368 | static ɵfac: i0.ɵɵFactoryDeclaration<FormControlDirective, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }, { optional: true; }]>;
|
2369 | static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlDirective, "[formControl]", ["ngForm"], { "form": { "alias": "formControl"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, false, never>;
|
2370 | }
|
2371 |
|
2372 | /**
|
2373 | * @description
|
2374 | * Syncs a `FormControl` in an existing `FormGroup` to a form control
|
2375 | * element by name.
|
2376 | *
|
2377 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
2378 | * @see {@link FormControl}
|
2379 | * @see {@link AbstractControl}
|
2380 | *
|
2381 | * @usageNotes
|
2382 | *
|
2383 | * ### Register `FormControl` within a group
|
2384 | *
|
2385 | * The following example shows how to register multiple form controls within a form group
|
2386 | * and set their value.
|
2387 | *
|
2388 | * {@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
|
2389 | *
|
2390 | * To see `formControlName` examples with different form control types, see:
|
2391 | *
|
2392 | * * Radio buttons: `RadioControlValueAccessor`
|
2393 | * * Selects: `SelectControlValueAccessor`
|
2394 | *
|
2395 | * ### Use with ngModel is deprecated
|
2396 | *
|
2397 | * Support for using the `ngModel` input property and `ngModelChange` event with reactive
|
2398 | * form directives has been deprecated in Angular v6 and is scheduled for removal in
|
2399 | * a future version of Angular.
|
2400 | *
|
2401 | * @ngModule ReactiveFormsModule
|
2402 | * @publicApi
|
2403 | */
|
2404 | export declare class FormControlName extends NgControl implements OnChanges, OnDestroy {
|
2405 | private _ngModelWarningConfig;
|
2406 | private _added;
|
2407 | /**
|
2408 | * @description
|
2409 | * Tracks the `FormControl` instance bound to the directive.
|
2410 | */
|
2411 | readonly control: FormControl;
|
2412 | /**
|
2413 | * @description
|
2414 | * Tracks the name of the `FormControl` bound to the directive. The name corresponds
|
2415 | * to a key in the parent `FormGroup` or `FormArray`.
|
2416 | * Accepts a name as a string or a number.
|
2417 | * The name in the form of a string is useful for individual forms,
|
2418 | * while the numerical form allows for form controls to be bound
|
2419 | * to indices when iterating over controls in a `FormArray`.
|
2420 | */
|
2421 | name: string | number | null;
|
2422 | /**
|
2423 | * @description
|
2424 | * Triggers a warning in dev mode that this input should not be used with reactive forms.
|
2425 | */
|
2426 | set isDisabled(isDisabled: boolean);
|
2427 | /** @deprecated as of v6 */
|
2428 | model: any;
|
2429 | /** @deprecated as of v6 */
|
2430 | update: EventEmitter<any>;
|
2431 | constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], valueAccessors: ControlValueAccessor[], _ngModelWarningConfig: string | null);
|
2432 | /** @nodoc */
|
2433 | ngOnChanges(changes: SimpleChanges): void;
|
2434 | /** @nodoc */
|
2435 | ngOnDestroy(): void;
|
2436 | /**
|
2437 | * @description
|
2438 | * Sets the new value for the view model and emits an `ngModelChange` event.
|
2439 | *
|
2440 | * @param newValue The new value for the view model.
|
2441 | */
|
2442 | viewToModelUpdate(newValue: any): void;
|
2443 | /**
|
2444 | * @description
|
2445 | * Returns an array that represents the path from the top-level form to this control.
|
2446 | * Each index is the string name of the control on that level.
|
2447 | */
|
2448 | get path(): string[];
|
2449 | /**
|
2450 | * @description
|
2451 | * The top-level directive for this group if present, otherwise null.
|
2452 | */
|
2453 | get formDirective(): any;
|
2454 | private _checkParentType;
|
2455 | private _setUpControl;
|
2456 | static ɵfac: i0.ɵɵFactoryDeclaration<FormControlName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }]>;
|
2457 | static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlName, "[formControlName]", never, { "name": { "alias": "formControlName"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, false, never>;
|
2458 | }
|
2459 |
|
2460 | /**
|
2461 | * Interface for options provided to a `FormControl`.
|
2462 | *
|
2463 | * This interface extends all options from {@link AbstractControlOptions}, plus some options
|
2464 | * unique to `FormControl`.
|
2465 | *
|
2466 | * @publicApi
|
2467 | */
|
2468 | export declare interface FormControlOptions extends AbstractControlOptions {
|
2469 | /**
|
2470 | * @description
|
2471 | * Whether to use the initial value used to construct the `FormControl` as its default value
|
2472 | * as well. If this option is false or not provided, the default value of a FormControl is `null`.
|
2473 | * When a FormControl is reset without an explicit value, its value reverts to
|
2474 | * its default value.
|
2475 | */
|
2476 | nonNullable?: boolean;
|
2477 | /**
|
2478 | * @deprecated Use `nonNullable` instead.
|
2479 | */
|
2480 | initialValueIsDefault?: boolean;
|
2481 | }
|
2482 |
|
2483 | /**
|
2484 | * FormControlState is a boxed form value. It is an object with a `value` key and a `disabled` key.
|
2485 | *
|
2486 | * @publicApi
|
2487 | */
|
2488 | export declare interface FormControlState<T> {
|
2489 | value: T;
|
2490 | disabled: boolean;
|
2491 | }
|
2492 |
|
2493 | /**
|
2494 | * A form can have several different statuses. Each
|
2495 | * possible status is returned as a string literal.
|
2496 | *
|
2497 | * * **VALID**: Reports that a control is valid, meaning that no errors exist in the input
|
2498 | * value.
|
2499 | * * **INVALID**: Reports that a control is invalid, meaning that an error exists in the input
|
2500 | * value.
|
2501 | * * **PENDING**: Reports that a control is pending, meaning that async validation is
|
2502 | * occurring and errors are not yet available for the input value.
|
2503 | * * **DISABLED**: Reports that a control is
|
2504 | * disabled, meaning that the control is exempt from ancestor calculations of validity or value.
|
2505 | *
|
2506 | * @publicApi
|
2507 | */
|
2508 | export declare type FormControlStatus = 'VALID' | 'INVALID' | 'PENDING' | 'DISABLED';
|
2509 |
|
2510 | /**
|
2511 | * Tracks the value and validity state of a group of `FormControl` instances.
|
2512 | *
|
2513 | * A `FormGroup` aggregates the values of each child `FormControl` into one object,
|
2514 | * with each control name as the key. It calculates its status by reducing the status values
|
2515 | * of its children. For example, if one of the controls in a group is invalid, the entire
|
2516 | * group becomes invalid.
|
2517 | *
|
2518 | * `FormGroup` is one of the four fundamental building blocks used to define forms in Angular,
|
2519 | * along with `FormControl`, `FormArray`, and `FormRecord`.
|
2520 | *
|
2521 | * When instantiating a `FormGroup`, pass in a collection of child controls as the first
|
2522 | * argument. The key for each child registers the name for the control.
|
2523 | *
|
2524 | * `FormGroup` is intended for use cases where the keys are known ahead of time.
|
2525 | * If you need to dynamically add and remove controls, use {@link FormRecord} instead.
|
2526 | *
|
2527 | * `FormGroup` accepts an optional type parameter `TControl`, which is an object type with inner
|
2528 | * control types as values.
|
2529 | *
|
2530 | * @usageNotes
|
2531 | *
|
2532 | * ### Create a form group with 2 controls
|
2533 | *
|
2534 | * ```
|
2535 | * const form = new FormGroup({
|
2536 | * first: new FormControl('Nancy', Validators.minLength(2)),
|
2537 | * last: new FormControl('Drew'),
|
2538 | * });
|
2539 | *
|
2540 | * console.log(form.value); // {first: 'Nancy', last; 'Drew'}
|
2541 | * console.log(form.status); // 'VALID'
|
2542 | * ```
|
2543 | *
|
2544 | * ### The type argument, and optional controls
|
2545 | *
|
2546 | * `FormGroup` accepts one generic argument, which is an object containing its inner controls.
|
2547 | * This type will usually be inferred automatically, but you can always specify it explicitly if you
|
2548 | * wish.
|
2549 | *
|
2550 | * If you have controls that are optional (i.e. they can be removed, you can use the `?` in the
|
2551 | * type):
|
2552 | *
|
2553 | * ```
|
2554 | * const form = new FormGroup<{
|
2555 | * first: FormControl<string|null>,
|
2556 | * middle?: FormControl<string|null>, // Middle name is optional.
|
2557 | * last: FormControl<string|null>,
|
2558 | * }>({
|
2559 | * first: new FormControl('Nancy'),
|
2560 | * last: new FormControl('Drew'),
|
2561 | * });
|
2562 | * ```
|
2563 | *
|
2564 | * ### Create a form group with a group-level validator
|
2565 | *
|
2566 | * You include group-level validators as the second arg, or group-level async
|
2567 | * validators as the third arg. These come in handy when you want to perform validation
|
2568 | * that considers the value of more than one child control.
|
2569 | *
|
2570 | * ```
|
2571 | * const form = new FormGroup({
|
2572 | * password: new FormControl('', Validators.minLength(2)),
|
2573 | * passwordConfirm: new FormControl('', Validators.minLength(2)),
|
2574 | * }, passwordMatchValidator);
|
2575 | *
|
2576 | *
|
2577 | * function passwordMatchValidator(g: FormGroup) {
|
2578 | * return g.get('password').value === g.get('passwordConfirm').value
|
2579 | * ? null : {'mismatch': true};
|
2580 | * }
|
2581 | * ```
|
2582 | *
|
2583 | * Like `FormControl` instances, you choose to pass in
|
2584 | * validators and async validators as part of an options object.
|
2585 | *
|
2586 | * ```
|
2587 | * const form = new FormGroup({
|
2588 | * password: new FormControl('')
|
2589 | * passwordConfirm: new FormControl('')
|
2590 | * }, { validators: passwordMatchValidator, asyncValidators: otherValidator });
|
2591 | * ```
|
2592 | *
|
2593 | * ### Set the updateOn property for all controls in a form group
|
2594 | *
|
2595 | * The options object is used to set a default value for each child
|
2596 | * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
|
2597 | * group level, all child controls default to 'blur', unless the child
|
2598 | * has explicitly specified a different `updateOn` value.
|
2599 | *
|
2600 | * ```ts
|
2601 | * const c = new FormGroup({
|
2602 | * one: new FormControl()
|
2603 | * }, { updateOn: 'blur' });
|
2604 | * ```
|
2605 | *
|
2606 | * ### Using a FormGroup with optional controls
|
2607 | *
|
2608 | * It is possible to have optional controls in a FormGroup. An optional control can be removed later
|
2609 | * using `removeControl`, and can be omitted when calling `reset`. Optional controls must be
|
2610 | * declared optional in the group's type.
|
2611 | *
|
2612 | * ```ts
|
2613 | * const c = new FormGroup<{one?: FormControl<string>}>({
|
2614 | * one: new FormControl('')
|
2615 | * });
|
2616 | * ```
|
2617 | *
|
2618 | * Notice that `c.value.one` has type `string|null|undefined`. This is because calling `c.reset({})`
|
2619 | * without providing the optional key `one` will cause it to become `null`.
|
2620 | *
|
2621 | * @publicApi
|
2622 | */
|
2623 | export declare class FormGroup<TControl extends {
|
2624 | [K in keyof TControl]: AbstractControl<any>;
|
2625 | } = any> extends AbstractControl<ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>, ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>> {
|
2626 | /**
|
2627 | * Creates a new `FormGroup` instance.
|
2628 | *
|
2629 | * @param controls A collection of child controls. The key for each child is the name
|
2630 | * under which it is registered.
|
2631 | *
|
2632 | * @param validatorOrOpts A synchronous validator function, or an array of
|
2633 | * such functions, or an `AbstractControlOptions` object that contains validation functions
|
2634 | * and a validation trigger.
|
2635 | *
|
2636 | * @param asyncValidator A single async validator or array of async validator functions
|
2637 | *
|
2638 | */
|
2639 | constructor(controls: TControl, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
|
2640 | controls: ɵTypedOrUntyped<TControl, TControl, {
|
2641 | [key: string]: AbstractControl<any>;
|
2642 | }>;
|
2643 | /**
|
2644 | * Registers a control with the group's list of controls. In a strongly-typed group, the control
|
2645 | * must be in the group's type (possibly as an optional key).
|
2646 | *
|
2647 | * This method does not update the value or validity of the control.
|
2648 | * Use {@link FormGroup#addControl addControl} instead.
|
2649 | *
|
2650 | * @param name The control name to register in the collection
|
2651 | * @param control Provides the control for the given name
|
2652 | */
|
2653 | registerControl<K extends string & keyof TControl>(name: K, control: TControl[K]): TControl[K];
|
2654 | registerControl(this: FormGroup<{
|
2655 | [key: string]: AbstractControl<any>;
|
2656 | }>, name: string, control: AbstractControl<any>): AbstractControl<any>;
|
2657 | /**
|
2658 | * Add a control to this group. In a strongly-typed group, the control must be in the group's type
|
2659 | * (possibly as an optional key).
|
2660 | *
|
2661 | * If a control with a given name already exists, it would *not* be replaced with a new one.
|
2662 | * If you want to replace an existing control, use the {@link FormGroup#setControl setControl}
|
2663 | * method instead. This method also updates the value and validity of the control.
|
2664 | *
|
2665 | * @param name The control name to add to the collection
|
2666 | * @param control Provides the control for the given name
|
2667 | * @param options Specifies whether this FormGroup instance should emit events after a new
|
2668 | * control is added.
|
2669 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2670 | * `valueChanges` observables emit events with the latest status and value when the control is
|
2671 | * added. When false, no events are emitted.
|
2672 | */
|
2673 | addControl(this: FormGroup<{
|
2674 | [key: string]: AbstractControl<any>;
|
2675 | }>, name: string, control: AbstractControl, options?: {
|
2676 | emitEvent?: boolean;
|
2677 | }): void;
|
2678 | addControl<K extends string & keyof TControl>(name: K, control: Required<TControl>[K], options?: {
|
2679 | emitEvent?: boolean;
|
2680 | }): void;
|
2681 | removeControl(this: FormGroup<{
|
2682 | [key: string]: AbstractControl<any>;
|
2683 | }>, name: string, options?: {
|
2684 | emitEvent?: boolean;
|
2685 | }): void;
|
2686 | removeControl<S extends string>(name: ɵOptionalKeys<TControl> & S, options?: {
|
2687 | emitEvent?: boolean;
|
2688 | }): void;
|
2689 | /**
|
2690 | * Replace an existing control. In a strongly-typed group, the control must be in the group's type
|
2691 | * (possibly as an optional key).
|
2692 | *
|
2693 | * If a control with a given name does not exist in this `FormGroup`, it will be added.
|
2694 | *
|
2695 | * @param name The control name to replace in the collection
|
2696 | * @param control Provides the control for the given name
|
2697 | * @param options Specifies whether this FormGroup instance should emit events after an
|
2698 | * existing control is replaced.
|
2699 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2700 | * `valueChanges` observables emit events with the latest status and value when the control is
|
2701 | * replaced with a new one. When false, no events are emitted.
|
2702 | */
|
2703 | setControl<K extends string & keyof TControl>(name: K, control: TControl[K], options?: {
|
2704 | emitEvent?: boolean;
|
2705 | }): void;
|
2706 | setControl(this: FormGroup<{
|
2707 | [key: string]: AbstractControl<any>;
|
2708 | }>, name: string, control: AbstractControl, options?: {
|
2709 | emitEvent?: boolean;
|
2710 | }): void;
|
2711 | /**
|
2712 | * Check whether there is an enabled control with the given name in the group.
|
2713 | *
|
2714 | * Reports false for disabled controls. If you'd like to check for existence in the group
|
2715 | * only, use {@link AbstractControl#get get} instead.
|
2716 | *
|
2717 | * @param controlName The control name to check for existence in the collection
|
2718 | *
|
2719 | * @returns false for disabled controls, true otherwise.
|
2720 | */
|
2721 | contains<K extends string>(controlName: K): boolean;
|
2722 | contains(this: FormGroup<{
|
2723 | [key: string]: AbstractControl<any>;
|
2724 | }>, controlName: string): boolean;
|
2725 | /**
|
2726 | * Sets the value of the `FormGroup`. It accepts an object that matches
|
2727 | * the structure of the group, with control names as keys.
|
2728 | *
|
2729 | * @usageNotes
|
2730 | * ### Set the complete value for the form group
|
2731 | *
|
2732 | * ```
|
2733 | * const form = new FormGroup({
|
2734 | * first: new FormControl(),
|
2735 | * last: new FormControl()
|
2736 | * });
|
2737 | *
|
2738 | * console.log(form.value); // {first: null, last: null}
|
2739 | *
|
2740 | * form.setValue({first: 'Nancy', last: 'Drew'});
|
2741 | * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
|
2742 | * ```
|
2743 | *
|
2744 | * @throws When strict checks fail, such as setting the value of a control
|
2745 | * that doesn't exist or if you exclude a value of a control that does exist.
|
2746 | *
|
2747 | * @param value The new value for the control that matches the structure of the group.
|
2748 | * @param options Configuration options that determine how the control propagates changes
|
2749 | * and emits events after the value changes.
|
2750 | * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
|
2751 | * updateValueAndValidity} method.
|
2752 | *
|
2753 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
|
2754 | * false.
|
2755 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2756 | * `valueChanges`
|
2757 | * observables emit events with the latest status and value when the control value is updated.
|
2758 | * When false, no events are emitted.
|
2759 | */
|
2760 | setValue(value: ɵFormGroupRawValue<TControl>, options?: {
|
2761 | onlySelf?: boolean;
|
2762 | emitEvent?: boolean;
|
2763 | }): void;
|
2764 | /**
|
2765 | * Patches the value of the `FormGroup`. It accepts an object with control
|
2766 | * names as keys, and does its best to match the values to the correct controls
|
2767 | * in the group.
|
2768 | *
|
2769 | * It accepts both super-sets and sub-sets of the group without throwing an error.
|
2770 | *
|
2771 | * @usageNotes
|
2772 | * ### Patch the value for a form group
|
2773 | *
|
2774 | * ```
|
2775 | * const form = new FormGroup({
|
2776 | * first: new FormControl(),
|
2777 | * last: new FormControl()
|
2778 | * });
|
2779 | * console.log(form.value); // {first: null, last: null}
|
2780 | *
|
2781 | * form.patchValue({first: 'Nancy'});
|
2782 | * console.log(form.value); // {first: 'Nancy', last: null}
|
2783 | * ```
|
2784 | *
|
2785 | * @param value The object that matches the structure of the group.
|
2786 | * @param options Configuration options that determine how the control propagates changes and
|
2787 | * emits events after the value is patched.
|
2788 | * * `onlySelf`: When true, each change only affects this control and not its parent. Default is
|
2789 | * true.
|
2790 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2791 | * `valueChanges` observables emit events with the latest status and value when the control value
|
2792 | * is updated. When false, no events are emitted. The configuration options are passed to
|
2793 | * the {@link AbstractControl#updateValueAndValidity updateValueAndValidity} method.
|
2794 | */
|
2795 | patchValue(value: ɵFormGroupValue<TControl>, options?: {
|
2796 | onlySelf?: boolean;
|
2797 | emitEvent?: boolean;
|
2798 | }): void;
|
2799 | /**
|
2800 | * Resets the `FormGroup`, marks all descendants `pristine` and `untouched` and sets
|
2801 | * the value of all descendants to their default values, or null if no defaults were provided.
|
2802 | *
|
2803 | * You reset to a specific form state by passing in a map of states
|
2804 | * that matches the structure of your form, with control names as keys. The state
|
2805 | * is a standalone value or a form state object with both a value and a disabled
|
2806 | * status.
|
2807 | *
|
2808 | * @param value Resets the control with an initial value,
|
2809 | * or an object that defines the initial value and disabled state.
|
2810 | *
|
2811 | * @param options Configuration options that determine how the control propagates changes
|
2812 | * and emits events when the group is reset.
|
2813 | * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is
|
2814 | * false.
|
2815 | * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and
|
2816 | * `valueChanges`
|
2817 | * observables emit events with the latest status and value when the control is reset.
|
2818 | * When false, no events are emitted.
|
2819 | * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity
|
2820 | * updateValueAndValidity} method.
|
2821 | *
|
2822 | * @usageNotes
|
2823 | *
|
2824 | * ### Reset the form group values
|
2825 | *
|
2826 | * ```ts
|
2827 | * const form = new FormGroup({
|
2828 | * first: new FormControl('first name'),
|
2829 | * last: new FormControl('last name')
|
2830 | * });
|
2831 | *
|
2832 | * console.log(form.value); // {first: 'first name', last: 'last name'}
|
2833 | *
|
2834 | * form.reset({ first: 'name', last: 'last name' });
|
2835 | *
|
2836 | * console.log(form.value); // {first: 'name', last: 'last name'}
|
2837 | * ```
|
2838 | *
|
2839 | * ### Reset the form group values and disabled status
|
2840 | *
|
2841 | * ```
|
2842 | * const form = new FormGroup({
|
2843 | * first: new FormControl('first name'),
|
2844 | * last: new FormControl('last name')
|
2845 | * });
|
2846 | *
|
2847 | * form.reset({
|
2848 | * first: {value: 'name', disabled: true},
|
2849 | * last: 'last'
|
2850 | * });
|
2851 | *
|
2852 | * console.log(form.value); // {last: 'last'}
|
2853 | * console.log(form.get('first').status); // 'DISABLED'
|
2854 | * ```
|
2855 | */
|
2856 | reset(value?: ɵTypedOrUntyped<TControl, ɵFormGroupValue<TControl>, any>, options?: {
|
2857 | onlySelf?: boolean;
|
2858 | emitEvent?: boolean;
|
2859 | }): void;
|
2860 | /**
|
2861 | * The aggregate value of the `FormGroup`, including any disabled controls.
|
2862 | *
|
2863 | * Retrieves all values regardless of disabled status.
|
2864 | */
|
2865 | getRawValue(): ɵTypedOrUntyped<TControl, ɵFormGroupRawValue<TControl>, any>;
|
2866 | }
|
2867 |
|
2868 | /**
|
2869 | * @description
|
2870 | *
|
2871 | * Binds an existing `FormGroup` or `FormRecord` to a DOM element.
|
2872 | *
|
2873 | * This directive accepts an existing `FormGroup` instance. It will then use this
|
2874 | * `FormGroup` instance to match any child `FormControl`, `FormGroup`/`FormRecord`,
|
2875 | * and `FormArray` instances to child `FormControlName`, `FormGroupName`,
|
2876 | * and `FormArrayName` directives.
|
2877 | *
|
2878 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
2879 | * @see {@link AbstractControl}
|
2880 | *
|
2881 | * @usageNotes
|
2882 | * ### Register Form Group
|
2883 | *
|
2884 | * The following example registers a `FormGroup` with first name and last name controls,
|
2885 | * and listens for the *ngSubmit* event when the button is clicked.
|
2886 | *
|
2887 | * {@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
|
2888 | *
|
2889 | * @ngModule ReactiveFormsModule
|
2890 | * @publicApi
|
2891 | */
|
2892 | export declare class FormGroupDirective extends ControlContainer implements Form, OnChanges, OnDestroy {
|
2893 | private callSetDisabledState?;
|
2894 | /**
|
2895 | * @description
|
2896 | * Reports whether the form submission has been triggered.
|
2897 | */
|
2898 | get submitted(): boolean;
|
2899 | private set submitted(value);
|
2900 | private readonly _submittedReactive;
|
2901 | /**
|
2902 | * Reference to an old form group input value, which is needed to cleanup
|
2903 | * old instance in case it was replaced with a new one.
|
2904 | */
|
2905 | private _oldForm;
|
2906 | /**
|
2907 | * Callback that should be invoked when controls in FormGroup or FormArray collection change
|
2908 | * (added or removed). This callback triggers corresponding DOM updates.
|
2909 | */
|
2910 | private readonly _onCollectionChange;
|
2911 | /**
|
2912 | * @description
|
2913 | * Tracks the list of added `FormControlName` instances
|
2914 | */
|
2915 | directives: FormControlName[];
|
2916 | /**
|
2917 | * @description
|
2918 | * Tracks the `FormGroup` bound to this directive.
|
2919 | */
|
2920 | form: FormGroup;
|
2921 | /**
|
2922 | * @description
|
2923 | * Emits an event when the form submission has been triggered.
|
2924 | */
|
2925 | ngSubmit: EventEmitter<any>;
|
2926 | constructor(validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], callSetDisabledState?: SetDisabledStateOption | undefined);
|
2927 | /** @nodoc */
|
2928 | ngOnChanges(changes: SimpleChanges): void;
|
2929 | /** @nodoc */
|
2930 | ngOnDestroy(): void;
|
2931 | /**
|
2932 | * @description
|
2933 | * Returns this directive's instance.
|
2934 | */
|
2935 | get formDirective(): Form;
|
2936 | /**
|
2937 | * @description
|
2938 | * Returns the `FormGroup` bound to this directive.
|
2939 | */
|
2940 | get control(): FormGroup;
|
2941 | /**
|
2942 | * @description
|
2943 | * Returns an array representing the path to this group. Because this directive
|
2944 | * always lives at the top level of a form, it always an empty array.
|
2945 | */
|
2946 | get path(): string[];
|
2947 | /**
|
2948 | * @description
|
2949 | * Method that sets up the control directive in this group, re-calculates its value
|
2950 | * and validity, and adds the instance to the internal list of directives.
|
2951 | *
|
2952 | * @param dir The `FormControlName` directive instance.
|
2953 | */
|
2954 | addControl(dir: FormControlName): FormControl;
|
2955 | /**
|
2956 | * @description
|
2957 | * Retrieves the `FormControl` instance from the provided `FormControlName` directive
|
2958 | *
|
2959 | * @param dir The `FormControlName` directive instance.
|
2960 | */
|
2961 | getControl(dir: FormControlName): FormControl;
|
2962 | /**
|
2963 | * @description
|
2964 | * Removes the `FormControlName` instance from the internal list of directives
|
2965 | *
|
2966 | * @param dir The `FormControlName` directive instance.
|
2967 | */
|
2968 | removeControl(dir: FormControlName): void;
|
2969 | /**
|
2970 | * Adds a new `FormGroupName` directive instance to the form.
|
2971 | *
|
2972 | * @param dir The `FormGroupName` directive instance.
|
2973 | */
|
2974 | addFormGroup(dir: FormGroupName): void;
|
2975 | /**
|
2976 | * Performs the necessary cleanup when a `FormGroupName` directive instance is removed from the
|
2977 | * view.
|
2978 | *
|
2979 | * @param dir The `FormGroupName` directive instance.
|
2980 | */
|
2981 | removeFormGroup(dir: FormGroupName): void;
|
2982 | /**
|
2983 | * @description
|
2984 | * Retrieves the `FormGroup` for a provided `FormGroupName` directive instance
|
2985 | *
|
2986 | * @param dir The `FormGroupName` directive instance.
|
2987 | */
|
2988 | getFormGroup(dir: FormGroupName): FormGroup;
|
2989 | /**
|
2990 | * Performs the necessary setup when a `FormArrayName` directive instance is added to the view.
|
2991 | *
|
2992 | * @param dir The `FormArrayName` directive instance.
|
2993 | */
|
2994 | addFormArray(dir: FormArrayName): void;
|
2995 | /**
|
2996 | * Performs the necessary cleanup when a `FormArrayName` directive instance is removed from the
|
2997 | * view.
|
2998 | *
|
2999 | * @param dir The `FormArrayName` directive instance.
|
3000 | */
|
3001 | removeFormArray(dir: FormArrayName): void;
|
3002 | /**
|
3003 | * @description
|
3004 | * Retrieves the `FormArray` for a provided `FormArrayName` directive instance.
|
3005 | *
|
3006 | * @param dir The `FormArrayName` directive instance.
|
3007 | */
|
3008 | getFormArray(dir: FormArrayName): FormArray;
|
3009 | /**
|
3010 | * Sets the new value for the provided `FormControlName` directive.
|
3011 | *
|
3012 | * @param dir The `FormControlName` directive instance.
|
3013 | * @param value The new value for the directive's control.
|
3014 | */
|
3015 | updateModel(dir: FormControlName, value: any): void;
|
3016 | /**
|
3017 | * @description
|
3018 | * Method called with the "submit" event is triggered on the form.
|
3019 | * Triggers the `ngSubmit` emitter to emit the "submit" event as its payload.
|
3020 | *
|
3021 | * @param $event The "submit" event object
|
3022 | */
|
3023 | onSubmit($event: Event): boolean;
|
3024 | /**
|
3025 | * @description
|
3026 | * Method called when the "reset" event is triggered on the form.
|
3027 | */
|
3028 | onReset(): void;
|
3029 | /**
|
3030 | * @description
|
3031 | * Resets the form to an initial value and resets its submitted status.
|
3032 | *
|
3033 | * @param value The new value for the form.
|
3034 | */
|
3035 | resetForm(value?: any): void;
|
3036 | private _setUpFormContainer;
|
3037 | private _cleanUpFormContainer;
|
3038 | private _updateRegistrations;
|
3039 | private _updateValidators;
|
3040 | private _checkFormPresent;
|
3041 | static ɵfac: i0.ɵɵFactoryDeclaration<FormGroupDirective, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }]>;
|
3042 | static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupDirective, "[formGroup]", ["ngForm"], { "form": { "alias": "formGroup"; "required": false; }; }, { "ngSubmit": "ngSubmit"; }, never, never, false, never>;
|
3043 | }
|
3044 |
|
3045 | /**
|
3046 | * @description
|
3047 | *
|
3048 | * Syncs a nested `FormGroup` or `FormRecord` to a DOM element.
|
3049 | *
|
3050 | * This directive can only be used with a parent `FormGroupDirective`.
|
3051 | *
|
3052 | * It accepts the string name of the nested `FormGroup` or `FormRecord` to link, and
|
3053 | * looks for a `FormGroup` or `FormRecord` registered with that name in the parent
|
3054 | * `FormGroup` instance you passed into `FormGroupDirective`.
|
3055 | *
|
3056 | * Use nested form groups to validate a sub-group of a
|
3057 | * form separately from the rest or to group the values of certain
|
3058 | * controls into their own nested object.
|
3059 | *
|
3060 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
3061 | *
|
3062 | * @usageNotes
|
3063 | *
|
3064 | * ### Access the group by name
|
3065 | *
|
3066 | * The following example uses the `AbstractControl.get` method to access the
|
3067 | * associated `FormGroup`
|
3068 | *
|
3069 | * ```ts
|
3070 | * this.form.get('name');
|
3071 | * ```
|
3072 | *
|
3073 | * ### Access individual controls in the group
|
3074 | *
|
3075 | * The following example uses the `AbstractControl.get` method to access
|
3076 | * individual controls within the group using dot syntax.
|
3077 | *
|
3078 | * ```ts
|
3079 | * this.form.get('name.first');
|
3080 | * ```
|
3081 | *
|
3082 | * ### Register a nested `FormGroup`.
|
3083 | *
|
3084 | * The following example registers a nested *name* `FormGroup` within an existing `FormGroup`,
|
3085 | * and provides methods to retrieve the nested `FormGroup` and individual controls.
|
3086 | *
|
3087 | * {@example forms/ts/nestedFormGroup/nested_form_group_example.ts region='Component'}
|
3088 | *
|
3089 | * @ngModule ReactiveFormsModule
|
3090 | * @publicApi
|
3091 | */
|
3092 | export declare class FormGroupName extends AbstractFormGroupDirective implements OnInit, OnDestroy {
|
3093 | /**
|
3094 | * @description
|
3095 | * Tracks the name of the `FormGroup` bound to the directive. The name corresponds
|
3096 | * to a key in the parent `FormGroup` or `FormArray`.
|
3097 | * Accepts a name as a string or a number.
|
3098 | * The name in the form of a string is useful for individual forms,
|
3099 | * while the numerical form allows for form groups to be bound
|
3100 | * to indices when iterating over groups in a `FormArray`.
|
3101 | */
|
3102 | name: string | number | null;
|
3103 | constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[]);
|
3104 | static ɵfac: i0.ɵɵFactoryDeclaration<FormGroupName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>;
|
3105 | static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupName, "[formGroupName]", never, { "name": { "alias": "formGroupName"; "required": false; }; }, {}, never, never, false, never>;
|
3106 | }
|
3107 |
|
3108 | declare type FormHooks = 'change' | 'blur' | 'submit';
|
3109 |
|
3110 | /**
|
3111 | * Tracks the value and validity state of a collection of `FormControl` instances, each of which has
|
3112 | * the same value type.
|
3113 | *
|
3114 | * `FormRecord` is very similar to {@link FormGroup}, except it can be used with a dynamic keys,
|
3115 | * with controls added and removed as needed.
|
3116 | *
|
3117 | * `FormRecord` accepts one generic argument, which describes the type of the controls it contains.
|
3118 | *
|
3119 | * @usageNotes
|
3120 | *
|
3121 | * ```
|
3122 | * let numbers = new FormRecord({bill: new FormControl('415-123-456')});
|
3123 | * numbers.addControl('bob', new FormControl('415-234-567'));
|
3124 | * numbers.removeControl('bill');
|
3125 | * ```
|
3126 | *
|
3127 | * @publicApi
|
3128 | */
|
3129 | export declare class FormRecord<TControl extends AbstractControl = AbstractControl> extends FormGroup<{
|
3130 | [key: string]: TControl;
|
3131 | }> {
|
3132 | }
|
3133 |
|
3134 | export declare interface FormRecord<TControl> {
|
3135 | /**
|
3136 | * Registers a control with the records's list of controls.
|
3137 | *
|
3138 | * See `FormGroup#registerControl` for additional information.
|
3139 | */
|
3140 | registerControl(name: string, control: TControl): TControl;
|
3141 | /**
|
3142 | * Add a control to this group.
|
3143 | *
|
3144 | * See `FormGroup#addControl` for additional information.
|
3145 | */
|
3146 | addControl(name: string, control: TControl, options?: {
|
3147 | emitEvent?: boolean;
|
3148 | }): void;
|
3149 | /**
|
3150 | * Remove a control from this group.
|
3151 | *
|
3152 | * See `FormGroup#removeControl` for additional information.
|
3153 | */
|
3154 | removeControl(name: string, options?: {
|
3155 | emitEvent?: boolean;
|
3156 | }): void;
|
3157 | /**
|
3158 | * Replace an existing control.
|
3159 | *
|
3160 | * See `FormGroup#setControl` for additional information.
|
3161 | */
|
3162 | setControl(name: string, control: TControl, options?: {
|
3163 | emitEvent?: boolean;
|
3164 | }): void;
|
3165 | /**
|
3166 | * Check whether there is an enabled control with the given name in the group.
|
3167 | *
|
3168 | * See `FormGroup#contains` for additional information.
|
3169 | */
|
3170 | contains(controlName: string): boolean;
|
3171 | /**
|
3172 | * Sets the value of the `FormRecord`. It accepts an object that matches
|
3173 | * the structure of the group, with control names as keys.
|
3174 | *
|
3175 | * See `FormGroup#setValue` for additional information.
|
3176 | */
|
3177 | setValue(value: {
|
3178 | [key: string]: ɵValue<TControl>;
|
3179 | }, options?: {
|
3180 | onlySelf?: boolean;
|
3181 | emitEvent?: boolean;
|
3182 | }): void;
|
3183 | /**
|
3184 | * Patches the value of the `FormRecord`. It accepts an object with control
|
3185 | * names as keys, and does its best to match the values to the correct controls
|
3186 | * in the group.
|
3187 | *
|
3188 | * See `FormGroup#patchValue` for additional information.
|
3189 | */
|
3190 | patchValue(value: {
|
3191 | [key: string]: ɵValue<TControl>;
|
3192 | }, options?: {
|
3193 | onlySelf?: boolean;
|
3194 | emitEvent?: boolean;
|
3195 | }): void;
|
3196 | /**
|
3197 | * Resets the `FormRecord`, marks all descendants `pristine` and `untouched` and sets
|
3198 | * the value of all descendants to null.
|
3199 | *
|
3200 | * See `FormGroup#reset` for additional information.
|
3201 | */
|
3202 | reset(value?: {
|
3203 | [key: string]: ɵValue<TControl>;
|
3204 | }, options?: {
|
3205 | onlySelf?: boolean;
|
3206 | emitEvent?: boolean;
|
3207 | }): void;
|
3208 | /**
|
3209 | * The aggregate value of the `FormRecord`, including any disabled controls.
|
3210 | *
|
3211 | * See `FormGroup#getRawValue` for additional information.
|
3212 | */
|
3213 | getRawValue(): {
|
3214 | [key: string]: ɵRawValue<TControl>;
|
3215 | };
|
3216 | }
|
3217 |
|
3218 | /**
|
3219 | * Event fired when a form is reset.
|
3220 | *
|
3221 | * @publicApi
|
3222 | */
|
3223 | export declare class FormResetEvent extends ControlEvent {
|
3224 | readonly source: AbstractControl;
|
3225 | constructor(source: AbstractControl);
|
3226 | }
|
3227 |
|
3228 | /**
|
3229 | * Exports the required providers and directives for template-driven forms,
|
3230 | * making them available for import by NgModules that import this module.
|
3231 | *
|
3232 | * @see [Forms Overview](guide/forms)
|
3233 | * @see [Template-driven Forms Guide](guide/forms)
|
3234 | *
|
3235 | * @publicApi
|
3236 | */
|
3237 | export declare class FormsModule {
|
3238 | /**
|
3239 | * @description
|
3240 | * Provides options for configuring the forms module.
|
3241 | *
|
3242 | * @param opts An object of configuration options
|
3243 | * * `callSetDisabledState` Configures whether to `always` call `setDisabledState`, which is more
|
3244 | * correct, or to only call it `whenDisabled`, which is the legacy behavior.
|
3245 | */
|
3246 | static withConfig(opts: {
|
3247 | callSetDisabledState?: SetDisabledStateOption;
|
3248 | }): ModuleWithProviders<FormsModule>;
|
3249 | static ɵfac: i0.ɵɵFactoryDeclaration<FormsModule, never>;
|
3250 | static ɵmod: i0.ɵɵNgModuleDeclaration<FormsModule, [typeof i1_2.NgModel, typeof i2_2.NgModelGroup, typeof i3_2.NgForm], never, [typeof i4_2.ɵInternalFormsSharedModule, typeof i1_2.NgModel, typeof i2_2.NgModelGroup, typeof i3_2.NgForm]>;
|
3251 | static ɵinj: i0.ɵɵInjectorDeclaration<FormsModule>;
|
3252 | }
|
3253 |
|
3254 | /**
|
3255 | * Event fired when a form is submitted
|
3256 | *
|
3257 | * @publicApi
|
3258 | */
|
3259 | export declare class FormSubmittedEvent extends ControlEvent {
|
3260 | readonly source: AbstractControl;
|
3261 | constructor(source: AbstractControl);
|
3262 | }
|
3263 |
|
3264 | declare namespace i1 {
|
3265 | export {
|
3266 | ɵNgNoValidate,
|
3267 | ɵNgNoValidate as NgNoValidate
|
3268 | }
|
3269 | }
|
3270 |
|
3271 | declare namespace i10 {
|
3272 | export {
|
3273 | ValidationErrors,
|
3274 | Validator,
|
3275 | MAX_VALIDATOR,
|
3276 | MaxValidator,
|
3277 | MIN_VALIDATOR,
|
3278 | MinValidator,
|
3279 | AsyncValidator,
|
3280 | REQUIRED_VALIDATOR,
|
3281 | CHECKBOX_REQUIRED_VALIDATOR,
|
3282 | RequiredValidator,
|
3283 | CheckboxRequiredValidator,
|
3284 | EMAIL_VALIDATOR,
|
3285 | EmailValidator,
|
3286 | ValidatorFn,
|
3287 | AsyncValidatorFn,
|
3288 | MIN_LENGTH_VALIDATOR,
|
3289 | MinLengthValidator,
|
3290 | MAX_LENGTH_VALIDATOR,
|
3291 | MaxLengthValidator,
|
3292 | PATTERN_VALIDATOR,
|
3293 | PatternValidator
|
3294 | }
|
3295 | }
|
3296 |
|
3297 | declare namespace i1_2 {
|
3298 | export {
|
3299 | NgModel
|
3300 | }
|
3301 | }
|
3302 |
|
3303 | declare namespace i2 {
|
3304 | export {
|
3305 | SelectControlValueAccessor,
|
3306 | NgSelectOption
|
3307 | }
|
3308 | }
|
3309 |
|
3310 | declare namespace i2_2 {
|
3311 | export {
|
3312 | modelGroupProvider,
|
3313 | NgModelGroup
|
3314 | }
|
3315 | }
|
3316 |
|
3317 | declare namespace i3 {
|
3318 | export {
|
3319 | SelectMultipleControlValueAccessor,
|
3320 | ɵNgSelectMultipleOption,
|
3321 | ɵNgSelectMultipleOption as NgSelectMultipleOption
|
3322 | }
|
3323 | }
|
3324 |
|
3325 | declare namespace i3_2 {
|
3326 | export {
|
3327 | NgForm
|
3328 | }
|
3329 | }
|
3330 |
|
3331 | declare namespace i4 {
|
3332 | export {
|
3333 | DEFAULT_VALUE_ACCESSOR,
|
3334 | COMPOSITION_BUFFER_MODE,
|
3335 | DefaultValueAccessor
|
3336 | }
|
3337 | }
|
3338 |
|
3339 | declare namespace i4_2 {
|
3340 | export {
|
3341 | CheckboxControlValueAccessor,
|
3342 | ControlValueAccessor,
|
3343 | DefaultValueAccessor,
|
3344 | NgControl,
|
3345 | NgControlStatus,
|
3346 | NgControlStatusGroup,
|
3347 | NgForm,
|
3348 | NgModel,
|
3349 | NgModelGroup,
|
3350 | NumberValueAccessor,
|
3351 | RadioControlValueAccessor,
|
3352 | RangeValueAccessor,
|
3353 | FormControlDirective,
|
3354 | NG_MODEL_WITH_FORM_CONTROL_WARNING,
|
3355 | FormControlName,
|
3356 | FormGroupDirective,
|
3357 | FormArrayName,
|
3358 | FormGroupName,
|
3359 | NgSelectOption,
|
3360 | SelectControlValueAccessor,
|
3361 | ɵNgSelectMultipleOption as NgSelectMultipleOption,
|
3362 | SelectMultipleControlValueAccessor,
|
3363 | CALL_SET_DISABLED_STATE,
|
3364 | SHARED_FORM_DIRECTIVES,
|
3365 | TEMPLATE_DRIVEN_DIRECTIVES,
|
3366 | REACTIVE_DRIVEN_DIRECTIVES,
|
3367 | ɵInternalFormsSharedModule,
|
3368 | ɵInternalFormsSharedModule as InternalFormsSharedModule
|
3369 | }
|
3370 | }
|
3371 |
|
3372 | declare namespace i5 {
|
3373 | export {
|
3374 | NumberValueAccessor
|
3375 | }
|
3376 | }
|
3377 |
|
3378 | declare namespace i5_2 {
|
3379 | export {
|
3380 | NG_MODEL_WITH_FORM_CONTROL_WARNING,
|
3381 | FormControlDirective
|
3382 | }
|
3383 | }
|
3384 |
|
3385 | declare namespace i6 {
|
3386 | export {
|
3387 | RangeValueAccessor
|
3388 | }
|
3389 | }
|
3390 |
|
3391 | declare namespace i6_2 {
|
3392 | export {
|
3393 | FormGroupDirective
|
3394 | }
|
3395 | }
|
3396 |
|
3397 | declare namespace i7 {
|
3398 | export {
|
3399 | CheckboxControlValueAccessor
|
3400 | }
|
3401 | }
|
3402 |
|
3403 | declare namespace i7_2 {
|
3404 | export {
|
3405 | FormControlName
|
3406 | }
|
3407 | }
|
3408 |
|
3409 | declare namespace i8 {
|
3410 | export {
|
3411 | RadioControlRegistry,
|
3412 | RadioControlValueAccessor
|
3413 | }
|
3414 | }
|
3415 |
|
3416 | declare namespace i8_2 {
|
3417 | export {
|
3418 | FormGroupName,
|
3419 | formArrayNameProvider,
|
3420 | FormArrayName
|
3421 | }
|
3422 | }
|
3423 |
|
3424 | declare namespace i9 {
|
3425 | export {
|
3426 | AbstractControlStatus,
|
3427 | ngControlStatusHost,
|
3428 | ngGroupStatusHost,
|
3429 | NgControlStatus,
|
3430 | NgControlStatusGroup
|
3431 | }
|
3432 | }
|
3433 |
|
3434 | /**
|
3435 | * @description
|
3436 | * Asserts that the given control is an instance of `FormArray`
|
3437 | *
|
3438 | * @publicApi
|
3439 | */
|
3440 | export declare const isFormArray: (control: unknown) => control is FormArray;
|
3441 |
|
3442 | /**
|
3443 | * @description
|
3444 | * Asserts that the given control is an instance of `FormControl`
|
3445 | *
|
3446 | * @publicApi
|
3447 | */
|
3448 | export declare const isFormControl: (control: unknown) => control is FormControl;
|
3449 |
|
3450 | /**
|
3451 | * @description
|
3452 | * Asserts that the given control is an instance of `FormGroup`
|
3453 | *
|
3454 | * @publicApi
|
3455 | */
|
3456 | export declare const isFormGroup: (control: unknown) => control is FormGroup;
|
3457 |
|
3458 | /**
|
3459 | * @description
|
3460 | * Asserts that the given control is an instance of `FormRecord`
|
3461 | *
|
3462 | * @publicApi
|
3463 | */
|
3464 | export declare const isFormRecord: (control: unknown) => control is FormRecord;
|
3465 |
|
3466 | /**
|
3467 | * @description
|
3468 | * Provider which adds `MaxLengthValidator` to the `NG_VALIDATORS` multi-provider list.
|
3469 | */
|
3470 | declare const MAX_LENGTH_VALIDATOR: any;
|
3471 |
|
3472 | /**
|
3473 | * @description
|
3474 | * Provider which adds `MaxValidator` to the `NG_VALIDATORS` multi-provider list.
|
3475 | */
|
3476 | declare const MAX_VALIDATOR: Provider;
|
3477 |
|
3478 | /**
|
3479 | * A directive that adds maximum length validation to controls marked with the
|
3480 | * `maxlength` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
3481 | *
|
3482 | * @see [Form Validation](guide/forms/form-validation)
|
3483 | *
|
3484 | * @usageNotes
|
3485 | *
|
3486 | * ### Adding a maximum length validator
|
3487 | *
|
3488 | * The following example shows how to add a maximum length validator to an input attached to an
|
3489 | * ngModel binding.
|
3490 | *
|
3491 | * ```html
|
3492 | * <input name="firstName" ngModel maxlength="25">
|
3493 | * ```
|
3494 | *
|
3495 | * @ngModule ReactiveFormsModule
|
3496 | * @ngModule FormsModule
|
3497 | * @publicApi
|
3498 | */
|
3499 | export declare class MaxLengthValidator extends AbstractValidatorDirective {
|
3500 | /**
|
3501 | * @description
|
3502 | * Tracks changes to the maximum length bound to this directive.
|
3503 | */
|
3504 | maxlength: string | number | null;
|
3505 | static ɵfac: i0.ɵɵFactoryDeclaration<MaxLengthValidator, never>;
|
3506 | static ɵdir: i0.ɵɵDirectiveDeclaration<MaxLengthValidator, "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", never, { "maxlength": { "alias": "maxlength"; "required": false; }; }, {}, never, never, false, never>;
|
3507 | }
|
3508 |
|
3509 | /**
|
3510 | * A directive which installs the {@link MaxValidator} for any `formControlName`,
|
3511 | * `formControl`, or control with `ngModel` that also has a `max` attribute.
|
3512 | *
|
3513 | * @see [Form Validation](guide/forms/form-validation)
|
3514 | *
|
3515 | * @usageNotes
|
3516 | *
|
3517 | * ### Adding a max validator
|
3518 | *
|
3519 | * The following example shows how to add a max validator to an input attached to an
|
3520 | * ngModel binding.
|
3521 | *
|
3522 | * ```html
|
3523 | * <input type="number" ngModel max="4">
|
3524 | * ```
|
3525 | *
|
3526 | * @ngModule ReactiveFormsModule
|
3527 | * @ngModule FormsModule
|
3528 | * @publicApi
|
3529 | */
|
3530 | export declare class MaxValidator extends AbstractValidatorDirective {
|
3531 | /**
|
3532 | * @description
|
3533 | * Tracks changes to the max bound to this directive.
|
3534 | */
|
3535 | max: string | number | null;
|
3536 | static ɵfac: i0.ɵɵFactoryDeclaration<MaxValidator, never>;
|
3537 | static ɵdir: i0.ɵɵDirectiveDeclaration<MaxValidator, "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", never, { "max": { "alias": "max"; "required": false; }; }, {}, never, never, false, never>;
|
3538 | }
|
3539 |
|
3540 | /**
|
3541 | * @description
|
3542 | * Provider which adds `MinLengthValidator` to the `NG_VALIDATORS` multi-provider list.
|
3543 | */
|
3544 | declare const MIN_LENGTH_VALIDATOR: any;
|
3545 |
|
3546 | /**
|
3547 | * @description
|
3548 | * Provider which adds `MinValidator` to the `NG_VALIDATORS` multi-provider list.
|
3549 | */
|
3550 | declare const MIN_VALIDATOR: Provider;
|
3551 |
|
3552 | /**
|
3553 | * A directive that adds minimum length validation to controls marked with the
|
3554 | * `minlength` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
3555 | *
|
3556 | * @see [Form Validation](guide/forms/form-validation)
|
3557 | *
|
3558 | * @usageNotes
|
3559 | *
|
3560 | * ### Adding a minimum length validator
|
3561 | *
|
3562 | * The following example shows how to add a minimum length validator to an input attached to an
|
3563 | * ngModel binding.
|
3564 | *
|
3565 | * ```html
|
3566 | * <input name="firstName" ngModel minlength="4">
|
3567 | * ```
|
3568 | *
|
3569 | * @ngModule ReactiveFormsModule
|
3570 | * @ngModule FormsModule
|
3571 | * @publicApi
|
3572 | */
|
3573 | export declare class MinLengthValidator extends AbstractValidatorDirective {
|
3574 | /**
|
3575 | * @description
|
3576 | * Tracks changes to the minimum length bound to this directive.
|
3577 | */
|
3578 | minlength: string | number | null;
|
3579 | static ɵfac: i0.ɵɵFactoryDeclaration<MinLengthValidator, never>;
|
3580 | static ɵdir: i0.ɵɵDirectiveDeclaration<MinLengthValidator, "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", never, { "minlength": { "alias": "minlength"; "required": false; }; }, {}, never, never, false, never>;
|
3581 | }
|
3582 |
|
3583 | /**
|
3584 | * A directive which installs the {@link MinValidator} for any `formControlName`,
|
3585 | * `formControl`, or control with `ngModel` that also has a `min` attribute.
|
3586 | *
|
3587 | * @see [Form Validation](guide/forms/form-validation)
|
3588 | *
|
3589 | * @usageNotes
|
3590 | *
|
3591 | * ### Adding a min validator
|
3592 | *
|
3593 | * The following example shows how to add a min validator to an input attached to an
|
3594 | * ngModel binding.
|
3595 | *
|
3596 | * ```html
|
3597 | * <input type="number" ngModel min="4">
|
3598 | * ```
|
3599 | *
|
3600 | * @ngModule ReactiveFormsModule
|
3601 | * @ngModule FormsModule
|
3602 | * @publicApi
|
3603 | */
|
3604 | export declare class MinValidator extends AbstractValidatorDirective {
|
3605 | /**
|
3606 | * @description
|
3607 | * Tracks changes to the min bound to this directive.
|
3608 | */
|
3609 | min: string | number | null;
|
3610 | static ɵfac: i0.ɵɵFactoryDeclaration<MinValidator, never>;
|
3611 | static ɵdir: i0.ɵɵDirectiveDeclaration<MinValidator, "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", never, { "min": { "alias": "min"; "required": false; }; }, {}, never, never, false, never>;
|
3612 | }
|
3613 |
|
3614 | declare const modelGroupProvider: any;
|
3615 |
|
3616 | /**
|
3617 | * @description
|
3618 | * An `InjectionToken` for registering additional asynchronous validators used with
|
3619 | * `AbstractControl`s.
|
3620 | *
|
3621 | * @see {@link NG_VALIDATORS}
|
3622 | *
|
3623 | * @usageNotes
|
3624 | *
|
3625 | * ### Provide a custom async validator directive
|
3626 | *
|
3627 | * The following example implements the `AsyncValidator` interface to create an
|
3628 | * async validator directive with a custom error key.
|
3629 | *
|
3630 | * ```typescript
|
3631 | * @Directive({
|
3632 | * selector: '[customAsyncValidator]',
|
3633 | * providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi:
|
3634 | * true}]
|
3635 | * })
|
3636 | * class CustomAsyncValidatorDirective implements AsyncValidator {
|
3637 | * validate(control: AbstractControl): Promise<ValidationErrors|null> {
|
3638 | * return Promise.resolve({'custom': true});
|
3639 | * }
|
3640 | * }
|
3641 | * ```
|
3642 | *
|
3643 | * @publicApi
|
3644 | */
|
3645 | export declare const NG_ASYNC_VALIDATORS: InjectionToken<readonly (Function | Validator)[]>;
|
3646 |
|
3647 | /**
|
3648 | * Token to provide to turn off the ngModel warning on formControl and formControlName.
|
3649 | */
|
3650 | declare const NG_MODEL_WITH_FORM_CONTROL_WARNING: InjectionToken<unknown>;
|
3651 |
|
3652 | /**
|
3653 | * @description
|
3654 | * An `InjectionToken` for registering additional synchronous validators used with
|
3655 | * `AbstractControl`s.
|
3656 | *
|
3657 | * @see {@link NG_ASYNC_VALIDATORS}
|
3658 | *
|
3659 | * @usageNotes
|
3660 | *
|
3661 | * ### Providing a custom validator
|
3662 | *
|
3663 | * The following example registers a custom validator directive. Adding the validator to the
|
3664 | * existing collection of validators requires the `multi: true` option.
|
3665 | *
|
3666 | * ```typescript
|
3667 | * @Directive({
|
3668 | * selector: '[customValidator]',
|
3669 | * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
|
3670 | * })
|
3671 | * class CustomValidatorDirective implements Validator {
|
3672 | * validate(control: AbstractControl): ValidationErrors | null {
|
3673 | * return { 'custom': true };
|
3674 | * }
|
3675 | * }
|
3676 | * ```
|
3677 | *
|
3678 | * @publicApi
|
3679 | */
|
3680 | export declare const NG_VALIDATORS: InjectionToken<readonly (Function | Validator)[]>;
|
3681 |
|
3682 | /**
|
3683 | * Used to provide a `ControlValueAccessor` for form controls.
|
3684 | *
|
3685 | * See `DefaultValueAccessor` for how to implement one.
|
3686 | *
|
3687 | * @publicApi
|
3688 | */
|
3689 | export declare const NG_VALUE_ACCESSOR: InjectionToken<readonly ControlValueAccessor[]>;
|
3690 |
|
3691 | /**
|
3692 | * @description
|
3693 | * A base class that all `FormControl`-based directives extend. It binds a `FormControl`
|
3694 | * object to a DOM element.
|
3695 | *
|
3696 | * @publicApi
|
3697 | */
|
3698 | export declare abstract class NgControl extends AbstractControlDirective {
|
3699 | /**
|
3700 | * @description
|
3701 | * The name for the control
|
3702 | */
|
3703 | name: string | number | null;
|
3704 | /**
|
3705 | * @description
|
3706 | * The value accessor for the control
|
3707 | */
|
3708 | valueAccessor: ControlValueAccessor | null;
|
3709 | /**
|
3710 | * @description
|
3711 | * The callback method to update the model from the view when requested
|
3712 | *
|
3713 | * @param newValue The new value for the view
|
3714 | */
|
3715 | abstract viewToModelUpdate(newValue: any): void;
|
3716 | }
|
3717 |
|
3718 | /**
|
3719 | * @description
|
3720 | * Directive automatically applied to Angular form controls that sets CSS classes
|
3721 | * based on control status.
|
3722 | *
|
3723 | * @usageNotes
|
3724 | *
|
3725 | * ### CSS classes applied
|
3726 | *
|
3727 | * The following classes are applied as the properties become true:
|
3728 | *
|
3729 | * * ng-valid
|
3730 | * * ng-invalid
|
3731 | * * ng-pending
|
3732 | * * ng-pristine
|
3733 | * * ng-dirty
|
3734 | * * ng-untouched
|
3735 | * * ng-touched
|
3736 | *
|
3737 | * @ngModule ReactiveFormsModule
|
3738 | * @ngModule FormsModule
|
3739 | * @publicApi
|
3740 | */
|
3741 | export declare class NgControlStatus extends AbstractControlStatus {
|
3742 | constructor(cd: NgControl);
|
3743 | static ɵfac: i0.ɵɵFactoryDeclaration<NgControlStatus, [{ self: true; }]>;
|
3744 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgControlStatus, "[formControlName],[ngModel],[formControl]", never, {}, {}, never, never, false, never>;
|
3745 | }
|
3746 |
|
3747 | /**
|
3748 | * @description
|
3749 | * Directive automatically applied to Angular form groups that sets CSS classes
|
3750 | * based on control status (valid/invalid/dirty/etc). On groups, this includes the additional
|
3751 | * class ng-submitted.
|
3752 | *
|
3753 | * @see {@link NgControlStatus}
|
3754 | *
|
3755 | * @ngModule ReactiveFormsModule
|
3756 | * @ngModule FormsModule
|
3757 | * @publicApi
|
3758 | */
|
3759 | export declare class NgControlStatusGroup extends AbstractControlStatus {
|
3760 | constructor(cd: ControlContainer);
|
3761 | static ɵfac: i0.ɵɵFactoryDeclaration<NgControlStatusGroup, [{ optional: true; self: true; }]>;
|
3762 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgControlStatusGroup, "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]", never, {}, {}, never, never, false, never>;
|
3763 | }
|
3764 |
|
3765 | declare const ngControlStatusHost: {
|
3766 | '[class.ng-untouched]': string;
|
3767 | '[class.ng-touched]': string;
|
3768 | '[class.ng-pristine]': string;
|
3769 | '[class.ng-dirty]': string;
|
3770 | '[class.ng-valid]': string;
|
3771 | '[class.ng-invalid]': string;
|
3772 | '[class.ng-pending]': string;
|
3773 | };
|
3774 |
|
3775 | /**
|
3776 | * @description
|
3777 | * Creates a top-level `FormGroup` instance and binds it to a form
|
3778 | * to track aggregate form value and validation status.
|
3779 | *
|
3780 | * As soon as you import the `FormsModule`, this directive becomes active by default on
|
3781 | * all `<form>` tags. You don't need to add a special selector.
|
3782 | *
|
3783 | * You optionally export the directive into a local template variable using `ngForm` as the key
|
3784 | * (ex: `#myForm="ngForm"`). This is optional, but useful. Many properties from the underlying
|
3785 | * `FormGroup` instance are duplicated on the directive itself, so a reference to it
|
3786 | * gives you access to the aggregate value and validity status of the form, as well as
|
3787 | * user interaction properties like `dirty` and `touched`.
|
3788 | *
|
3789 | * To register child controls with the form, use `NgModel` with a `name`
|
3790 | * attribute. You may use `NgModelGroup` to create sub-groups within the form.
|
3791 | *
|
3792 | * If necessary, listen to the directive's `ngSubmit` event to be notified when the user has
|
3793 | * triggered a form submission. The `ngSubmit` event emits the original form
|
3794 | * submission event.
|
3795 | *
|
3796 | * In template driven forms, all `<form>` tags are automatically tagged as `NgForm`.
|
3797 | * To import the `FormsModule` but skip its usage in some forms,
|
3798 | * for example, to use native HTML5 validation, add the `ngNoForm` and the `<form>`
|
3799 | * tags won't create an `NgForm` directive. In reactive forms, using `ngNoForm` is
|
3800 | * unnecessary because the `<form>` tags are inert. In that case, you would
|
3801 | * refrain from using the `formGroup` directive.
|
3802 | *
|
3803 | * @usageNotes
|
3804 | *
|
3805 | * ### Listening for form submission
|
3806 | *
|
3807 | * The following example shows how to capture the form values from the "ngSubmit" event.
|
3808 | *
|
3809 | * {@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
|
3810 | *
|
3811 | * ### Setting the update options
|
3812 | *
|
3813 | * The following example shows you how to change the "updateOn" option from its default using
|
3814 | * ngFormOptions.
|
3815 | *
|
3816 | * ```html
|
3817 | * <form [ngFormOptions]="{updateOn: 'blur'}">
|
3818 | * <input name="one" ngModel> <!-- this ngModel will update on blur -->
|
3819 | * </form>
|
3820 | * ```
|
3821 | *
|
3822 | * ### Native DOM validation UI
|
3823 | *
|
3824 | * In order to prevent the native DOM form validation UI from interfering with Angular's form
|
3825 | * validation, Angular automatically adds the `novalidate` attribute on any `<form>` whenever
|
3826 | * `FormModule` or `ReactiveFormModule` are imported into the application.
|
3827 | * If you want to explicitly enable native DOM validation UI with Angular forms, you can add the
|
3828 | * `ngNativeValidate` attribute to the `<form>` element:
|
3829 | *
|
3830 | * ```html
|
3831 | * <form ngNativeValidate>
|
3832 | * ...
|
3833 | * </form>
|
3834 | * ```
|
3835 | *
|
3836 | * @ngModule FormsModule
|
3837 | * @publicApi
|
3838 | */
|
3839 | export declare class NgForm extends ControlContainer implements Form, AfterViewInit {
|
3840 | private callSetDisabledState?;
|
3841 | /**
|
3842 | * @description
|
3843 | * Returns whether the form submission has been triggered.
|
3844 | */
|
3845 | get submitted(): boolean;
|
3846 | private readonly submittedReactive;
|
3847 | private _directives;
|
3848 | /**
|
3849 | * @description
|
3850 | * The `FormGroup` instance created for this form.
|
3851 | */
|
3852 | form: FormGroup;
|
3853 | /**
|
3854 | * @description
|
3855 | * Event emitter for the "ngSubmit" event
|
3856 | */
|
3857 | ngSubmit: EventEmitter<any>;
|
3858 | /**
|
3859 | * @description
|
3860 | * Tracks options for the `NgForm` instance.
|
3861 | *
|
3862 | * **updateOn**: Sets the default `updateOn` value for all child `NgModels` below it
|
3863 | * unless explicitly set by a child `NgModel` using `ngModelOptions`). Defaults to 'change'.
|
3864 | * Possible values: `'change'` | `'blur'` | `'submit'`.
|
3865 | *
|
3866 | */
|
3867 | options: {
|
3868 | updateOn?: FormHooks;
|
3869 | };
|
3870 | constructor(validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], callSetDisabledState?: SetDisabledStateOption | undefined);
|
3871 | /** @nodoc */
|
3872 | ngAfterViewInit(): void;
|
3873 | /**
|
3874 | * @description
|
3875 | * The directive instance.
|
3876 | */
|
3877 | get formDirective(): Form;
|
3878 | /**
|
3879 | * @description
|
3880 | * The internal `FormGroup` instance.
|
3881 | */
|
3882 | get control(): FormGroup;
|
3883 | /**
|
3884 | * @description
|
3885 | * Returns an array representing the path to this group. Because this directive
|
3886 | * always lives at the top level of a form, it is always an empty array.
|
3887 | */
|
3888 | get path(): string[];
|
3889 | /**
|
3890 | * @description
|
3891 | * Returns a map of the controls in this group.
|
3892 | */
|
3893 | get controls(): {
|
3894 | [key: string]: AbstractControl;
|
3895 | };
|
3896 | /**
|
3897 | * @description
|
3898 | * Method that sets up the control directive in this group, re-calculates its value
|
3899 | * and validity, and adds the instance to the internal list of directives.
|
3900 | *
|
3901 | * @param dir The `NgModel` directive instance.
|
3902 | */
|
3903 | addControl(dir: NgModel): void;
|
3904 | /**
|
3905 | * @description
|
3906 | * Retrieves the `FormControl` instance from the provided `NgModel` directive.
|
3907 | *
|
3908 | * @param dir The `NgModel` directive instance.
|
3909 | */
|
3910 | getControl(dir: NgModel): FormControl;
|
3911 | /**
|
3912 | * @description
|
3913 | * Removes the `NgModel` instance from the internal list of directives
|
3914 | *
|
3915 | * @param dir The `NgModel` directive instance.
|
3916 | */
|
3917 | removeControl(dir: NgModel): void;
|
3918 | /**
|
3919 | * @description
|
3920 | * Adds a new `NgModelGroup` directive instance to the form.
|
3921 | *
|
3922 | * @param dir The `NgModelGroup` directive instance.
|
3923 | */
|
3924 | addFormGroup(dir: NgModelGroup): void;
|
3925 | /**
|
3926 | * @description
|
3927 | * Removes the `NgModelGroup` directive instance from the form.
|
3928 | *
|
3929 | * @param dir The `NgModelGroup` directive instance.
|
3930 | */
|
3931 | removeFormGroup(dir: NgModelGroup): void;
|
3932 | /**
|
3933 | * @description
|
3934 | * Retrieves the `FormGroup` for a provided `NgModelGroup` directive instance
|
3935 | *
|
3936 | * @param dir The `NgModelGroup` directive instance.
|
3937 | */
|
3938 | getFormGroup(dir: NgModelGroup): FormGroup;
|
3939 | /**
|
3940 | * Sets the new value for the provided `NgControl` directive.
|
3941 | *
|
3942 | * @param dir The `NgControl` directive instance.
|
3943 | * @param value The new value for the directive's control.
|
3944 | */
|
3945 | updateModel(dir: NgControl, value: any): void;
|
3946 | /**
|
3947 | * @description
|
3948 | * Sets the value for this `FormGroup`.
|
3949 | *
|
3950 | * @param value The new value
|
3951 | */
|
3952 | setValue(value: {
|
3953 | [key: string]: any;
|
3954 | }): void;
|
3955 | /**
|
3956 | * @description
|
3957 | * Method called when the "submit" event is triggered on the form.
|
3958 | * Triggers the `ngSubmit` emitter to emit the "submit" event as its payload.
|
3959 | *
|
3960 | * @param $event The "submit" event object
|
3961 | */
|
3962 | onSubmit($event: Event): boolean;
|
3963 | /**
|
3964 | * @description
|
3965 | * Method called when the "reset" event is triggered on the form.
|
3966 | */
|
3967 | onReset(): void;
|
3968 | /**
|
3969 | * @description
|
3970 | * Resets the form to an initial value and resets its submitted status.
|
3971 | *
|
3972 | * @param value The new value for the form.
|
3973 | */
|
3974 | resetForm(value?: any): void;
|
3975 | private _setUpdateStrategy;
|
3976 | private _findContainer;
|
3977 | static ɵfac: i0.ɵɵFactoryDeclaration<NgForm, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }]>;
|
3978 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgForm, "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", ["ngForm"], { "options": { "alias": "ngFormOptions"; "required": false; }; }, { "ngSubmit": "ngSubmit"; }, never, never, false, never>;
|
3979 | }
|
3980 |
|
3981 | declare const ngGroupStatusHost: {
|
3982 | '[class.ng-submitted]': string;
|
3983 | '[class.ng-untouched]': string;
|
3984 | '[class.ng-touched]': string;
|
3985 | '[class.ng-pristine]': string;
|
3986 | '[class.ng-dirty]': string;
|
3987 | '[class.ng-valid]': string;
|
3988 | '[class.ng-invalid]': string;
|
3989 | '[class.ng-pending]': string;
|
3990 | };
|
3991 |
|
3992 | /**
|
3993 | * @description
|
3994 | * Creates a `FormControl` instance from a [domain
|
3995 | * model](https://en.wikipedia.org/wiki/Domain_model) and binds it to a form control element.
|
3996 | *
|
3997 | * The `FormControl` instance tracks the value, user interaction, and
|
3998 | * validation status of the control and keeps the view synced with the model. If used
|
3999 | * within a parent form, the directive also registers itself with the form as a child
|
4000 | * control.
|
4001 | *
|
4002 | * This directive is used by itself or as part of a larger form. Use the
|
4003 | * `ngModel` selector to activate it.
|
4004 | *
|
4005 | * It accepts a domain model as an optional `Input`. If you have a one-way binding
|
4006 | * to `ngModel` with `[]` syntax, changing the domain model's value in the component
|
4007 | * class sets the value in the view. If you have a two-way binding with `[()]` syntax
|
4008 | * (also known as 'banana-in-a-box syntax'), the value in the UI always syncs back to
|
4009 | * the domain model in your class.
|
4010 | *
|
4011 | * To inspect the properties of the associated `FormControl` (like the validity state),
|
4012 | * export the directive into a local template variable using `ngModel` as the key (ex:
|
4013 | * `#myVar="ngModel"`). You can then access the control using the directive's `control` property.
|
4014 | * However, the most commonly used properties (like `valid` and `dirty`) also exist on the control
|
4015 | * for direct access. See a full list of properties directly available in
|
4016 | * `AbstractControlDirective`.
|
4017 | *
|
4018 | * @see {@link RadioControlValueAccessor}
|
4019 | * @see {@link SelectControlValueAccessor}
|
4020 | *
|
4021 | * @usageNotes
|
4022 | *
|
4023 | * ### Using ngModel on a standalone control
|
4024 | *
|
4025 | * The following examples show a simple standalone control using `ngModel`:
|
4026 | *
|
4027 | * {@example forms/ts/simpleNgModel/simple_ng_model_example.ts region='Component'}
|
4028 | *
|
4029 | * When using the `ngModel` within `<form>` tags, you'll also need to supply a `name` attribute
|
4030 | * so that the control can be registered with the parent form under that name.
|
4031 | *
|
4032 | * In the context of a parent form, it's often unnecessary to include one-way or two-way binding,
|
4033 | * as the parent form syncs the value for you. You access its properties by exporting it into a
|
4034 | * local template variable using `ngForm` such as (`#f="ngForm"`). Use the variable where
|
4035 | * needed on form submission.
|
4036 | *
|
4037 | * If you do need to populate initial values into your form, using a one-way binding for
|
4038 | * `ngModel` tends to be sufficient as long as you use the exported form's value rather
|
4039 | * than the domain model's value on submit.
|
4040 | *
|
4041 | * ### Using ngModel within a form
|
4042 | *
|
4043 | * The following example shows controls using `ngModel` within a form:
|
4044 | *
|
4045 | * {@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
|
4046 | *
|
4047 | * ### Using a standalone ngModel within a group
|
4048 | *
|
4049 | * The following example shows you how to use a standalone ngModel control
|
4050 | * within a form. This controls the display of the form, but doesn't contain form data.
|
4051 | *
|
4052 | * ```html
|
4053 | * <form>
|
4054 | * <input name="login" ngModel placeholder="Login">
|
4055 | * <input type="checkbox" ngModel [ngModelOptions]="{standalone: true}"> Show more options?
|
4056 | * </form>
|
4057 | * <!-- form value: {login: ''} -->
|
4058 | * ```
|
4059 | *
|
4060 | * ### Setting the ngModel `name` attribute through options
|
4061 | *
|
4062 | * The following example shows you an alternate way to set the name attribute. Here,
|
4063 | * an attribute identified as name is used within a custom form control component. To still be able
|
4064 | * to specify the NgModel's name, you must specify it using the `ngModelOptions` input instead.
|
4065 | *
|
4066 | * ```html
|
4067 | * <form>
|
4068 | * <my-custom-form-control name="Nancy" ngModel [ngModelOptions]="{name: 'user'}">
|
4069 | * </my-custom-form-control>
|
4070 | * </form>
|
4071 | * <!-- form value: {user: ''} -->
|
4072 | * ```
|
4073 | *
|
4074 | * @ngModule FormsModule
|
4075 | * @publicApi
|
4076 | */
|
4077 | export declare class NgModel extends NgControl implements OnChanges, OnDestroy {
|
4078 | private _changeDetectorRef?;
|
4079 | private callSetDisabledState?;
|
4080 | readonly control: FormControl;
|
4081 | /** @nodoc */
|
4082 | static ngAcceptInputType_isDisabled: boolean | string;
|
4083 | /**
|
4084 | * Internal reference to the view model value.
|
4085 | * @nodoc
|
4086 | */
|
4087 | viewModel: any;
|
4088 | /**
|
4089 | * @description
|
4090 | * Tracks the name bound to the directive. If a parent form exists, it
|
4091 | * uses this name as a key to retrieve this control's value.
|
4092 | */
|
4093 | name: string;
|
4094 | /**
|
4095 | * @description
|
4096 | * Tracks whether the control is disabled.
|
4097 | */
|
4098 | isDisabled: boolean;
|
4099 | /**
|
4100 | * @description
|
4101 | * Tracks the value bound to this directive.
|
4102 | */
|
4103 | model: any;
|
4104 | /**
|
4105 | * @description
|
4106 | * Tracks the configuration options for this `ngModel` instance.
|
4107 | *
|
4108 | * **name**: An alternative to setting the name attribute on the form control element. See
|
4109 | * the [example](api/forms/NgModel#using-ngmodel-on-a-standalone-control) for using `NgModel`
|
4110 | * as a standalone control.
|
4111 | *
|
4112 | * **standalone**: When set to true, the `ngModel` will not register itself with its parent form,
|
4113 | * and acts as if it's not in the form. Defaults to false. If no parent form exists, this option
|
4114 | * has no effect.
|
4115 | *
|
4116 | * **updateOn**: Defines the event upon which the form control value and validity update.
|
4117 | * Defaults to 'change'. Possible values: `'change'` | `'blur'` | `'submit'`.
|
4118 | *
|
4119 | */
|
4120 | options: {
|
4121 | name?: string;
|
4122 | standalone?: boolean;
|
4123 | updateOn?: FormHooks;
|
4124 | };
|
4125 | /**
|
4126 | * @description
|
4127 | * Event emitter for producing the `ngModelChange` event after
|
4128 | * the view model updates.
|
4129 | */
|
4130 | update: EventEmitter<any>;
|
4131 | constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[], valueAccessors: ControlValueAccessor[], _changeDetectorRef?: (ChangeDetectorRef | null) | undefined, callSetDisabledState?: SetDisabledStateOption | undefined);
|
4132 | /** @nodoc */
|
4133 | ngOnChanges(changes: SimpleChanges): void;
|
4134 | /** @nodoc */
|
4135 | ngOnDestroy(): void;
|
4136 | /**
|
4137 | * @description
|
4138 | * Returns an array that represents the path from the top-level form to this control.
|
4139 | * Each index is the string name of the control on that level.
|
4140 | */
|
4141 | get path(): string[];
|
4142 | /**
|
4143 | * @description
|
4144 | * The top-level directive for this control if present, otherwise null.
|
4145 | */
|
4146 | get formDirective(): any;
|
4147 | /**
|
4148 | * @description
|
4149 | * Sets the new value for the view model and emits an `ngModelChange` event.
|
4150 | *
|
4151 | * @param newValue The new value emitted by `ngModelChange`.
|
4152 | */
|
4153 | viewToModelUpdate(newValue: any): void;
|
4154 | private _setUpControl;
|
4155 | private _setUpdateStrategy;
|
4156 | private _isStandalone;
|
4157 | private _setUpStandalone;
|
4158 | private _checkForErrors;
|
4159 | private _checkParentType;
|
4160 | private _checkName;
|
4161 | private _updateValue;
|
4162 | private _updateDisabled;
|
4163 | private _getPath;
|
4164 | static ɵfac: i0.ɵɵFactoryDeclaration<NgModel, [{ optional: true; host: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }, { optional: true; }]>;
|
4165 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgModel, "[ngModel]:not([formControlName]):not([formControl])", ["ngModel"], { "name": { "alias": "name"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; "options": { "alias": "ngModelOptions"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, false, never>;
|
4166 | }
|
4167 |
|
4168 | /**
|
4169 | * @description
|
4170 | * Creates and binds a `FormGroup` instance to a DOM element.
|
4171 | *
|
4172 | * This directive can only be used as a child of `NgForm` (within `<form>` tags).
|
4173 | *
|
4174 | * Use this directive to validate a sub-group of your form separately from the
|
4175 | * rest of your form, or if some values in your domain model make more sense
|
4176 | * to consume together in a nested object.
|
4177 | *
|
4178 | * Provide a name for the sub-group and it will become the key
|
4179 | * for the sub-group in the form's full value. If you need direct access, export the directive into
|
4180 | * a local template variable using `ngModelGroup` (ex: `#myGroup="ngModelGroup"`).
|
4181 | *
|
4182 | * @usageNotes
|
4183 | *
|
4184 | * ### Consuming controls in a grouping
|
4185 | *
|
4186 | * The following example shows you how to combine controls together in a sub-group
|
4187 | * of the form.
|
4188 | *
|
4189 | * {@example forms/ts/ngModelGroup/ng_model_group_example.ts region='Component'}
|
4190 | *
|
4191 | * @ngModule FormsModule
|
4192 | * @publicApi
|
4193 | */
|
4194 | export declare class NgModelGroup extends AbstractFormGroupDirective implements OnInit, OnDestroy {
|
4195 | /**
|
4196 | * @description
|
4197 | * Tracks the name of the `NgModelGroup` bound to the directive. The name corresponds
|
4198 | * to a key in the parent `NgForm`.
|
4199 | */
|
4200 | name: string;
|
4201 | constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[]);
|
4202 | static ɵfac: i0.ɵɵFactoryDeclaration<NgModelGroup, [{ host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>;
|
4203 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgModelGroup, "[ngModelGroup]", ["ngModelGroup"], { "name": { "alias": "ngModelGroup"; "required": false; }; }, {}, never, never, false, never>;
|
4204 | }
|
4205 |
|
4206 | /**
|
4207 | * @description
|
4208 | * Marks `<option>` as dynamic, so Angular can be notified when options change.
|
4209 | *
|
4210 | * @see {@link SelectControlValueAccessor}
|
4211 | *
|
4212 | * @ngModule ReactiveFormsModule
|
4213 | * @ngModule FormsModule
|
4214 | * @publicApi
|
4215 | */
|
4216 | export declare class NgSelectOption implements OnDestroy {
|
4217 | private _element;
|
4218 | private _renderer;
|
4219 | private _select;
|
4220 | /**
|
4221 | * @description
|
4222 | * ID of the option element
|
4223 | */
|
4224 | id: string;
|
4225 | constructor(_element: ElementRef, _renderer: Renderer2, _select: SelectControlValueAccessor);
|
4226 | /**
|
4227 | * @description
|
4228 | * Tracks the value bound to the option element. Unlike the value binding,
|
4229 | * ngValue supports binding to objects.
|
4230 | */
|
4231 | set ngValue(value: any);
|
4232 | /**
|
4233 | * @description
|
4234 | * Tracks simple string values bound to the option element.
|
4235 | * For objects, use the `ngValue` input binding.
|
4236 | */
|
4237 | set value(value: any);
|
4238 | /** @nodoc */
|
4239 | ngOnDestroy(): void;
|
4240 | static ɵfac: i0.ɵɵFactoryDeclaration<NgSelectOption, [null, null, { optional: true; host: true; }]>;
|
4241 | static ɵdir: i0.ɵɵDirectiveDeclaration<NgSelectOption, "option", never, { "ngValue": { "alias": "ngValue"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, false, never>;
|
4242 | }
|
4243 |
|
4244 | /**
|
4245 | * @description
|
4246 | * `NonNullableFormBuilder` is similar to {@link FormBuilder}, but automatically constructed
|
4247 | * {@link FormControl} elements have `{nonNullable: true}` and are non-nullable.
|
4248 | *
|
4249 | * @publicApi
|
4250 | */
|
4251 | export declare abstract class NonNullableFormBuilder {
|
4252 | /**
|
4253 | * Similar to `FormBuilder#group`, except any implicitly constructed `FormControl`
|
4254 | * will be non-nullable (i.e. it will have `nonNullable` set to true). Note
|
4255 | * that already-constructed controls will not be altered.
|
4256 | */
|
4257 | abstract group<T extends {}>(controls: T, options?: AbstractControlOptions | null): FormGroup<{
|
4258 | [K in keyof T]: ɵElement<T[K], never>;
|
4259 | }>;
|
4260 | /**
|
4261 | * Similar to `FormBuilder#record`, except any implicitly constructed `FormControl`
|
4262 | * will be non-nullable (i.e. it will have `nonNullable` set to true). Note
|
4263 | * that already-constructed controls will not be altered.
|
4264 | */
|
4265 | abstract record<T>(controls: {
|
4266 | [key: string]: T;
|
4267 | }, options?: AbstractControlOptions | null): FormRecord<ɵElement<T, never>>;
|
4268 | /**
|
4269 | * Similar to `FormBuilder#array`, except any implicitly constructed `FormControl`
|
4270 | * will be non-nullable (i.e. it will have `nonNullable` set to true). Note
|
4271 | * that already-constructed controls will not be altered.
|
4272 | */
|
4273 | abstract array<T>(controls: Array<T>, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormArray<ɵElement<T, never>>;
|
4274 | /**
|
4275 | * Similar to `FormBuilder#control`, except this overridden version of `control` forces
|
4276 | * `nonNullable` to be `true`, resulting in the control always being non-nullable.
|
4277 | */
|
4278 | abstract control<T>(formState: T | FormControlState<T>, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl<T>;
|
4279 | static ɵfac: i0.ɵɵFactoryDeclaration<NonNullableFormBuilder, never>;
|
4280 | static ɵprov: i0.ɵɵInjectableDeclaration<NonNullableFormBuilder>;
|
4281 | }
|
4282 |
|
4283 | /**
|
4284 | * @description
|
4285 | * The `ControlValueAccessor` for writing a number value and listening to number input changes.
|
4286 | * The value accessor is used by the `FormControlDirective`, `FormControlName`, and `NgModel`
|
4287 | * directives.
|
4288 | *
|
4289 | * @usageNotes
|
4290 | *
|
4291 | * ### Using a number input with a reactive form.
|
4292 | *
|
4293 | * The following example shows how to use a number input with a reactive form.
|
4294 | *
|
4295 | * ```ts
|
4296 | * const totalCountControl = new FormControl();
|
4297 | * ```
|
4298 | *
|
4299 | * ```
|
4300 | * <input type="number" [formControl]="totalCountControl">
|
4301 | * ```
|
4302 | *
|
4303 | * @ngModule ReactiveFormsModule
|
4304 | * @ngModule FormsModule
|
4305 | * @publicApi
|
4306 | */
|
4307 | export declare class NumberValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {
|
4308 | /**
|
4309 | * Sets the "value" property on the input element.
|
4310 | * @nodoc
|
4311 | */
|
4312 | writeValue(value: number): void;
|
4313 | /**
|
4314 | * Registers a function called when the control value changes.
|
4315 | * @nodoc
|
4316 | */
|
4317 | registerOnChange(fn: (_: number | null) => void): void;
|
4318 | static ɵfac: i0.ɵɵFactoryDeclaration<NumberValueAccessor, never>;
|
4319 | static ɵdir: i0.ɵɵDirectiveDeclaration<NumberValueAccessor, "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]", never, {}, {}, never, never, false, never>;
|
4320 | }
|
4321 |
|
4322 | /**
|
4323 | * @description
|
4324 | * Provider which adds `PatternValidator` to the `NG_VALIDATORS` multi-provider list.
|
4325 | */
|
4326 | declare const PATTERN_VALIDATOR: any;
|
4327 |
|
4328 | /**
|
4329 | * @description
|
4330 | * A directive that adds regex pattern validation to controls marked with the
|
4331 | * `pattern` attribute. The regex must match the entire control value.
|
4332 | * The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
4333 | *
|
4334 | * @see [Form Validation](guide/forms/form-validation)
|
4335 | *
|
4336 | * @usageNotes
|
4337 | *
|
4338 | * ### Adding a pattern validator
|
4339 | *
|
4340 | * The following example shows how to add a pattern validator to an input attached to an
|
4341 | * ngModel binding.
|
4342 | *
|
4343 | * ```html
|
4344 | * <input name="firstName" ngModel pattern="[a-zA-Z ]*">
|
4345 | * ```
|
4346 | *
|
4347 | * @ngModule ReactiveFormsModule
|
4348 | * @ngModule FormsModule
|
4349 | * @publicApi
|
4350 | */
|
4351 | export declare class PatternValidator extends AbstractValidatorDirective {
|
4352 | /**
|
4353 | * @description
|
4354 | * Tracks changes to the pattern bound to this directive.
|
4355 | */
|
4356 | pattern: string | RegExp;
|
4357 | static ɵfac: i0.ɵɵFactoryDeclaration<PatternValidator, never>;
|
4358 | static ɵdir: i0.ɵɵDirectiveDeclaration<PatternValidator, "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", never, { "pattern": { "alias": "pattern"; "required": false; }; }, {}, never, never, false, never>;
|
4359 | }
|
4360 |
|
4361 | /**
|
4362 | * Helper type to allow the compiler to accept [XXXX, { updateOn: string }] as a valid shorthand
|
4363 | * argument for .group()
|
4364 | */
|
4365 | declare interface PermissiveAbstractControlOptions extends Omit<AbstractControlOptions, 'updateOn'> {
|
4366 | updateOn?: string;
|
4367 | }
|
4368 |
|
4369 | /**
|
4370 | * The compiler may not always be able to prove that the elements of the control config are a tuple
|
4371 | * (i.e. occur in a fixed order). This slightly looser type is used for inference, to catch cases
|
4372 | * where the compiler cannot prove order and position.
|
4373 | *
|
4374 | * For example, consider the simple case `fb.group({foo: ['bar', Validators.required]})`. The
|
4375 | * compiler will infer this as an array, not as a tuple.
|
4376 | */
|
4377 | declare type PermissiveControlConfig<T> = Array<T | FormControlState<T> | ValidatorConfig>;
|
4378 |
|
4379 | /**
|
4380 | * Event fired when the control's pristine state changes (pristine <=> dirty).
|
4381 | *
|
4382 | * @publicApi */
|
4383 | export declare class PristineChangeEvent extends ControlEvent {
|
4384 | readonly pristine: boolean;
|
4385 | readonly source: AbstractControl;
|
4386 | constructor(pristine: boolean, source: AbstractControl);
|
4387 | }
|
4388 |
|
4389 | /**
|
4390 | * @description
|
4391 | * Class used by Angular to track radio buttons. For internal use only.
|
4392 | */
|
4393 | declare class RadioControlRegistry {
|
4394 | private _accessors;
|
4395 | /**
|
4396 | * @description
|
4397 | * Adds a control to the internal registry. For internal use only.
|
4398 | */
|
4399 | add(control: NgControl, accessor: RadioControlValueAccessor): void;
|
4400 | /**
|
4401 | * @description
|
4402 | * Removes a control from the internal registry. For internal use only.
|
4403 | */
|
4404 | remove(accessor: RadioControlValueAccessor): void;
|
4405 | /**
|
4406 | * @description
|
4407 | * Selects a radio button. For internal use only.
|
4408 | */
|
4409 | select(accessor: RadioControlValueAccessor): void;
|
4410 | private _isSameGroup;
|
4411 | static ɵfac: i0.ɵɵFactoryDeclaration<RadioControlRegistry, never>;
|
4412 | static ɵprov: i0.ɵɵInjectableDeclaration<RadioControlRegistry>;
|
4413 | }
|
4414 |
|
4415 | /**
|
4416 | * @description
|
4417 | * The `ControlValueAccessor` for writing radio control values and listening to radio control
|
4418 | * changes. The value accessor is used by the `FormControlDirective`, `FormControlName`, and
|
4419 | * `NgModel` directives.
|
4420 | *
|
4421 | * @usageNotes
|
4422 | *
|
4423 | * ### Using radio buttons with reactive form directives
|
4424 | *
|
4425 | * The follow example shows how to use radio buttons in a reactive form. When using radio buttons in
|
4426 | * a reactive form, radio buttons in the same group should have the same `formControlName`.
|
4427 | * Providing a `name` attribute is optional.
|
4428 | *
|
4429 | * {@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
|
4430 | *
|
4431 | * @ngModule ReactiveFormsModule
|
4432 | * @ngModule FormsModule
|
4433 | * @publicApi
|
4434 | */
|
4435 | export declare class RadioControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor, OnDestroy, OnInit {
|
4436 | private _registry;
|
4437 | private _injector;
|
4438 | private setDisabledStateFired;
|
4439 | /**
|
4440 | * The registered callback function called when a change event occurs on the input element.
|
4441 | * Note: we declare `onChange` here (also used as host listener) as a function with no arguments
|
4442 | * to override the `onChange` function (which expects 1 argument) in the parent
|
4443 | * `BaseControlValueAccessor` class.
|
4444 | * @nodoc
|
4445 | */
|
4446 | onChange: () => void;
|
4447 | /**
|
4448 | * @description
|
4449 | * Tracks the name of the radio input element.
|
4450 | */
|
4451 | name: string;
|
4452 | /**
|
4453 | * @description
|
4454 | * Tracks the name of the `FormControl` bound to the directive. The name corresponds
|
4455 | * to a key in the parent `FormGroup` or `FormArray`.
|
4456 | */
|
4457 | formControlName: string;
|
4458 | /**
|
4459 | * @description
|
4460 | * Tracks the value of the radio input element
|
4461 | */
|
4462 | value: any;
|
4463 | private callSetDisabledState;
|
4464 | constructor(renderer: Renderer2, elementRef: ElementRef, _registry: RadioControlRegistry, _injector: Injector);
|
4465 | /** @nodoc */
|
4466 | ngOnInit(): void;
|
4467 | /** @nodoc */
|
4468 | ngOnDestroy(): void;
|
4469 | /**
|
4470 | * Sets the "checked" property value on the radio input element.
|
4471 | * @nodoc
|
4472 | */
|
4473 | writeValue(value: any): void;
|
4474 | /**
|
4475 | * Registers a function called when the control value changes.
|
4476 | * @nodoc
|
4477 | */
|
4478 | registerOnChange(fn: (_: any) => {}): void;
|
4479 | /** @nodoc */
|
4480 | setDisabledState(isDisabled: boolean): void;
|
4481 | /**
|
4482 | * Sets the "value" on the radio input element and unchecks it.
|
4483 | *
|
4484 | * @param value
|
4485 | */
|
4486 | fireUncheck(value: any): void;
|
4487 | private _checkName;
|
4488 | static ɵfac: i0.ɵɵFactoryDeclaration<RadioControlValueAccessor, never>;
|
4489 | static ɵdir: i0.ɵɵDirectiveDeclaration<RadioControlValueAccessor, "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", never, { "name": { "alias": "name"; "required": false; }; "formControlName": { "alias": "formControlName"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, false, never>;
|
4490 | }
|
4491 |
|
4492 | /**
|
4493 | * @description
|
4494 | * The `ControlValueAccessor` for writing a range value and listening to range input changes.
|
4495 | * The value accessor is used by the `FormControlDirective`, `FormControlName`, and `NgModel`
|
4496 | * directives.
|
4497 | *
|
4498 | * @usageNotes
|
4499 | *
|
4500 | * ### Using a range input with a reactive form
|
4501 | *
|
4502 | * The following example shows how to use a range input with a reactive form.
|
4503 | *
|
4504 | * ```ts
|
4505 | * const ageControl = new FormControl();
|
4506 | * ```
|
4507 | *
|
4508 | * ```
|
4509 | * <input type="range" [formControl]="ageControl">
|
4510 | * ```
|
4511 | *
|
4512 | * @ngModule ReactiveFormsModule
|
4513 | * @ngModule FormsModule
|
4514 | * @publicApi
|
4515 | */
|
4516 | export declare class RangeValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {
|
4517 | /**
|
4518 | * Sets the "value" property on the input element.
|
4519 | * @nodoc
|
4520 | */
|
4521 | writeValue(value: any): void;
|
4522 | /**
|
4523 | * Registers a function called when the control value changes.
|
4524 | * @nodoc
|
4525 | */
|
4526 | registerOnChange(fn: (_: number | null) => void): void;
|
4527 | static ɵfac: i0.ɵɵFactoryDeclaration<RangeValueAccessor, never>;
|
4528 | static ɵdir: i0.ɵɵDirectiveDeclaration<RangeValueAccessor, "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]", never, {}, {}, never, never, false, never>;
|
4529 | }
|
4530 |
|
4531 | declare const REACTIVE_DRIVEN_DIRECTIVES: Type<any>[];
|
4532 |
|
4533 | /**
|
4534 | * Exports the required infrastructure and directives for reactive forms,
|
4535 | * making them available for import by NgModules that import this module.
|
4536 | *
|
4537 | * @see [Forms Overview](guide/forms)
|
4538 | * @see [Reactive Forms Guide](guide/forms/reactive-forms)
|
4539 | *
|
4540 | * @publicApi
|
4541 | */
|
4542 | export declare class ReactiveFormsModule {
|
4543 | /**
|
4544 | * @description
|
4545 | * Provides options for configuring the reactive forms module.
|
4546 | *
|
4547 | * @param opts An object of configuration options
|
4548 | * * `warnOnNgModelWithFormControl` Configures when to emit a warning when an `ngModel`
|
4549 | * binding is used with reactive form directives.
|
4550 | * * `callSetDisabledState` Configures whether to `always` call `setDisabledState`, which is more
|
4551 | * correct, or to only call it `whenDisabled`, which is the legacy behavior.
|
4552 | */
|
4553 | static withConfig(opts: {
|
4554 | /** @deprecated as of v6 */ warnOnNgModelWithFormControl?: 'never' | 'once' | 'always';
|
4555 | callSetDisabledState?: SetDisabledStateOption;
|
4556 | }): ModuleWithProviders<ReactiveFormsModule>;
|
4557 | static ɵfac: i0.ɵɵFactoryDeclaration<ReactiveFormsModule, never>;
|
4558 | static ɵmod: i0.ɵɵNgModuleDeclaration<ReactiveFormsModule, [typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName], never, [typeof i4_2.ɵInternalFormsSharedModule, typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName]>;
|
4559 | static ɵinj: i0.ɵɵInjectorDeclaration<ReactiveFormsModule>;
|
4560 | }
|
4561 |
|
4562 | /**
|
4563 | * @description
|
4564 | * Provider which adds `RequiredValidator` to the `NG_VALIDATORS` multi-provider list.
|
4565 | */
|
4566 | declare const REQUIRED_VALIDATOR: Provider;
|
4567 |
|
4568 | /**
|
4569 | * @description
|
4570 | * A directive that adds the `required` validator to any controls marked with the
|
4571 | * `required` attribute. The directive is provided with the `NG_VALIDATORS` multi-provider list.
|
4572 | *
|
4573 | * @see [Form Validation](guide/forms/form-validation)
|
4574 | *
|
4575 | * @usageNotes
|
4576 | *
|
4577 | * ### Adding a required validator using template-driven forms
|
4578 | *
|
4579 | * ```
|
4580 | * <input name="fullName" ngModel required>
|
4581 | * ```
|
4582 | *
|
4583 | * @ngModule FormsModule
|
4584 | * @ngModule ReactiveFormsModule
|
4585 | * @publicApi
|
4586 | */
|
4587 | export declare class RequiredValidator extends AbstractValidatorDirective {
|
4588 | /**
|
4589 | * @description
|
4590 | * Tracks changes to the required attribute bound to this directive.
|
4591 | */
|
4592 | required: boolean | string;
|
4593 | /** @nodoc */
|
4594 | enabled(input: boolean): boolean;
|
4595 | static ɵfac: i0.ɵɵFactoryDeclaration<RequiredValidator, never>;
|
4596 | static ɵdir: i0.ɵɵDirectiveDeclaration<RequiredValidator, ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", never, { "required": { "alias": "required"; "required": false; }; }, {}, never, never, false, never>;
|
4597 | }
|
4598 |
|
4599 | /**
|
4600 | * @description
|
4601 | * The `ControlValueAccessor` for writing select control values and listening to select control
|
4602 | * changes. The value accessor is used by the `FormControlDirective`, `FormControlName`, and
|
4603 | * `NgModel` directives.
|
4604 | *
|
4605 | * @usageNotes
|
4606 | *
|
4607 | * ### Using select controls in a reactive form
|
4608 | *
|
4609 | * The following examples show how to use a select control in a reactive form.
|
4610 | *
|
4611 | * {@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'}
|
4612 | *
|
4613 | * ### Using select controls in a template-driven form
|
4614 | *
|
4615 | * To use a select in a template-driven form, simply add an `ngModel` and a `name`
|
4616 | * attribute to the main `<select>` tag.
|
4617 | *
|
4618 | * {@example forms/ts/selectControl/select_control_example.ts region='Component'}
|
4619 | *
|
4620 | * ### Customizing option selection
|
4621 | *
|
4622 | * Angular uses object identity to select option. It's possible for the identities of items
|
4623 | * to change while the data does not. This can happen, for example, if the items are produced
|
4624 | * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
|
4625 | * second response will produce objects with different identities.
|
4626 | *
|
4627 | * To customize the default option comparison algorithm, `<select>` supports `compareWith` input.
|
4628 | * `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
|
4629 | * If `compareWith` is given, Angular selects option by the return value of the function.
|
4630 | *
|
4631 | * ```ts
|
4632 | * const selectedCountriesControl = new FormControl();
|
4633 | * ```
|
4634 | *
|
4635 | * ```
|
4636 | * <select [compareWith]="compareFn" [formControl]="selectedCountriesControl">
|
4637 | * <option *ngFor="let country of countries" [ngValue]="country">
|
4638 | * {{country.name}}
|
4639 | * </option>
|
4640 | * </select>
|
4641 | *
|
4642 | * compareFn(c1: Country, c2: Country): boolean {
|
4643 | * return c1 && c2 ? c1.id === c2.id : c1 === c2;
|
4644 | * }
|
4645 | * ```
|
4646 | *
|
4647 | * **Note:** We listen to the 'change' event because 'input' events aren't fired
|
4648 | * for selects in IE, see:
|
4649 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event#browser_compatibility
|
4650 | *
|
4651 | * @ngModule ReactiveFormsModule
|
4652 | * @ngModule FormsModule
|
4653 | * @publicApi
|
4654 | */
|
4655 | export declare class SelectControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {
|
4656 | /** @nodoc */
|
4657 | value: any;
|
4658 | /**
|
4659 | * @description
|
4660 | * Tracks the option comparison algorithm for tracking identities when
|
4661 | * checking for changes.
|
4662 | */
|
4663 | set compareWith(fn: (o1: any, o2: any) => boolean);
|
4664 | private _compareWith;
|
4665 | /**
|
4666 | * Sets the "value" property on the select element.
|
4667 | * @nodoc
|
4668 | */
|
4669 | writeValue(value: any): void;
|
4670 | /**
|
4671 | * Registers a function called when the control value changes.
|
4672 | * @nodoc
|
4673 | */
|
4674 | registerOnChange(fn: (value: any) => any): void;
|
4675 | static ɵfac: i0.ɵɵFactoryDeclaration<SelectControlValueAccessor, never>;
|
4676 | static ɵdir: i0.ɵɵDirectiveDeclaration<SelectControlValueAccessor, "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", never, { "compareWith": { "alias": "compareWith"; "required": false; }; }, {}, never, never, false, never>;
|
4677 | }
|
4678 |
|
4679 | /**
|
4680 | * @description
|
4681 | * The `ControlValueAccessor` for writing multi-select control values and listening to multi-select
|
4682 | * control changes. The value accessor is used by the `FormControlDirective`, `FormControlName`, and
|
4683 | * `NgModel` directives.
|
4684 | *
|
4685 | * @see {@link SelectControlValueAccessor}
|
4686 | *
|
4687 | * @usageNotes
|
4688 | *
|
4689 | * ### Using a multi-select control
|
4690 | *
|
4691 | * The follow example shows you how to use a multi-select control with a reactive form.
|
4692 | *
|
4693 | * ```ts
|
4694 | * const countryControl = new FormControl();
|
4695 | * ```
|
4696 | *
|
4697 | * ```
|
4698 | * <select multiple name="countries" [formControl]="countryControl">
|
4699 | * <option *ngFor="let country of countries" [ngValue]="country">
|
4700 | * {{ country.name }}
|
4701 | * </option>
|
4702 | * </select>
|
4703 | * ```
|
4704 | *
|
4705 | * ### Customizing option selection
|
4706 | *
|
4707 | * To customize the default option comparison algorithm, `<select>` supports `compareWith` input.
|
4708 | * See the `SelectControlValueAccessor` for usage.
|
4709 | *
|
4710 | * @ngModule ReactiveFormsModule
|
4711 | * @ngModule FormsModule
|
4712 | * @publicApi
|
4713 | */
|
4714 | export declare class SelectMultipleControlValueAccessor extends BuiltInControlValueAccessor implements ControlValueAccessor {
|
4715 | /**
|
4716 | * The current value.
|
4717 | * @nodoc
|
4718 | */
|
4719 | value: any;
|
4720 | /**
|
4721 | * @description
|
4722 | * Tracks the option comparison algorithm for tracking identities when
|
4723 | * checking for changes.
|
4724 | */
|
4725 | set compareWith(fn: (o1: any, o2: any) => boolean);
|
4726 | private _compareWith;
|
4727 | /**
|
4728 | * Sets the "value" property on one or of more of the select's options.
|
4729 | * @nodoc
|
4730 | */
|
4731 | writeValue(value: any): void;
|
4732 | /**
|
4733 | * Registers a function called when the control value changes
|
4734 | * and writes an array of the selected options.
|
4735 | * @nodoc
|
4736 | */
|
4737 | registerOnChange(fn: (value: any) => any): void;
|
4738 | static ɵfac: i0.ɵɵFactoryDeclaration<SelectMultipleControlValueAccessor, never>;
|
4739 | static ɵdir: i0.ɵɵDirectiveDeclaration<SelectMultipleControlValueAccessor, "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", never, { "compareWith": { "alias": "compareWith"; "required": false; }; }, {}, never, never, false, never>;
|
4740 | }
|
4741 |
|
4742 | /**
|
4743 | * The type for CALL_SET_DISABLED_STATE. If `always`, then ControlValueAccessor will always call
|
4744 | * `setDisabledState` when attached, which is the most correct behavior. Otherwise, it will only be
|
4745 | * called when disabled, which is the legacy behavior for compatibility.
|
4746 | *
|
4747 | * @publicApi
|
4748 | * @see {@link FormsModule#withconfig}
|
4749 | */
|
4750 | export declare type SetDisabledStateOption = 'whenDisabledForLegacyCode' | 'always';
|
4751 |
|
4752 | declare const SHARED_FORM_DIRECTIVES: Type<any>[];
|
4753 |
|
4754 | /**
|
4755 | * Event fired when the control's status changes.
|
4756 | *
|
4757 | * @publicApi
|
4758 | */
|
4759 | export declare class StatusChangeEvent extends ControlEvent {
|
4760 | readonly status: FormControlStatus;
|
4761 | readonly source: AbstractControl;
|
4762 | constructor(status: FormControlStatus, source: AbstractControl);
|
4763 | }
|
4764 |
|
4765 | declare const TEMPLATE_DRIVEN_DIRECTIVES: Type<any>[];
|
4766 |
|
4767 | /**
|
4768 | * Event fired when the control's touched status changes (touched <=> untouched).
|
4769 | *
|
4770 | * @publicApi
|
4771 | */
|
4772 | export declare class TouchedChangeEvent extends ControlEvent {
|
4773 | readonly touched: boolean;
|
4774 | readonly source: AbstractControl;
|
4775 | constructor(touched: boolean, source: AbstractControl);
|
4776 | }
|
4777 |
|
4778 | /**
|
4779 | * UntypedFormArray is a non-strongly-typed version of `FormArray`, which
|
4780 | * permits heterogenous controls.
|
4781 | */
|
4782 | export declare type UntypedFormArray = FormArray<any>;
|
4783 |
|
4784 | export declare const UntypedFormArray: UntypedFormArrayCtor;
|
4785 |
|
4786 | declare interface UntypedFormArrayCtor {
|
4787 | new (controls: AbstractControl[], validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormArray;
|
4788 | /**
|
4789 | * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
|
4790 | * manually inspect the prototype chain.
|
4791 | */
|
4792 | prototype: FormArray<any>;
|
4793 | }
|
4794 |
|
4795 | /**
|
4796 | * UntypedFormBuilder is the same as `FormBuilder`, but it provides untyped controls.
|
4797 | */
|
4798 | export declare class UntypedFormBuilder extends FormBuilder {
|
4799 | /**
|
4800 | * Like `FormBuilder#group`, except the resulting group is untyped.
|
4801 | */
|
4802 | group(controlsConfig: {
|
4803 | [key: string]: any;
|
4804 | }, options?: AbstractControlOptions | null): UntypedFormGroup;
|
4805 | /**
|
4806 | * @deprecated This API is not typesafe and can result in issues with Closure Compiler renaming.
|
4807 | * Use the `FormBuilder#group` overload with `AbstractControlOptions` instead.
|
4808 | */
|
4809 | group(controlsConfig: {
|
4810 | [key: string]: any;
|
4811 | }, options: {
|
4812 | [key: string]: any;
|
4813 | }): UntypedFormGroup;
|
4814 | /**
|
4815 | * Like `FormBuilder#control`, except the resulting control is untyped.
|
4816 | */
|
4817 | control(formState: any, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormControl;
|
4818 | /**
|
4819 | * Like `FormBuilder#array`, except the resulting array is untyped.
|
4820 | */
|
4821 | array(controlsConfig: any[], validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormArray;
|
4822 | static ɵfac: i0.ɵɵFactoryDeclaration<UntypedFormBuilder, never>;
|
4823 | static ɵprov: i0.ɵɵInjectableDeclaration<UntypedFormBuilder>;
|
4824 | }
|
4825 |
|
4826 | /**
|
4827 | * UntypedFormControl is a non-strongly-typed version of `FormControl`.
|
4828 | */
|
4829 | export declare type UntypedFormControl = FormControl<any>;
|
4830 |
|
4831 | export declare const UntypedFormControl: UntypedFormControlCtor;
|
4832 |
|
4833 | declare interface UntypedFormControlCtor {
|
4834 | new (): UntypedFormControl;
|
4835 | new (formState?: any, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormControl;
|
4836 | /**
|
4837 | * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
|
4838 | * manually inspect the prototype chain.
|
4839 | */
|
4840 | prototype: FormControl<any>;
|
4841 | }
|
4842 |
|
4843 | /**
|
4844 | * UntypedFormGroup is a non-strongly-typed version of `FormGroup`.
|
4845 | */
|
4846 | export declare type UntypedFormGroup = FormGroup<any>;
|
4847 |
|
4848 | export declare const UntypedFormGroup: UntypedFormGroupCtor;
|
4849 |
|
4850 | declare interface UntypedFormGroupCtor {
|
4851 | new (controls: {
|
4852 | [key: string]: AbstractControl;
|
4853 | }, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): UntypedFormGroup;
|
4854 | /**
|
4855 | * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
|
4856 | * manually inspect the prototype chain.
|
4857 | */
|
4858 | prototype: FormGroup<any>;
|
4859 | }
|
4860 |
|
4861 | /**
|
4862 | * @description
|
4863 | * Defines the map of errors returned from failed validation checks.
|
4864 | *
|
4865 | * @publicApi
|
4866 | */
|
4867 | export declare type ValidationErrors = {
|
4868 | [key: string]: any;
|
4869 | };
|
4870 |
|
4871 | /**
|
4872 | * @description
|
4873 | * An interface implemented by classes that perform synchronous validation.
|
4874 | *
|
4875 | * @usageNotes
|
4876 | *
|
4877 | * ### Provide a custom validator
|
4878 | *
|
4879 | * The following example implements the `Validator` interface to create a
|
4880 | * validator directive with a custom error key.
|
4881 | *
|
4882 | * ```typescript
|
4883 | * @Directive({
|
4884 | * selector: '[customValidator]',
|
4885 | * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
|
4886 | * })
|
4887 | * class CustomValidatorDirective implements Validator {
|
4888 | * validate(control: AbstractControl): ValidationErrors|null {
|
4889 | * return {'custom': true};
|
4890 | * }
|
4891 | * }
|
4892 | * ```
|
4893 | *
|
4894 | * @publicApi
|
4895 | */
|
4896 | export declare interface Validator {
|
4897 | /**
|
4898 | * @description
|
4899 | * Method that performs synchronous validation against the provided control.
|
4900 | *
|
4901 | * @param control The control to validate against.
|
4902 | *
|
4903 | * @returns A map of validation errors if validation fails,
|
4904 | * otherwise null.
|
4905 | */
|
4906 | validate(control: AbstractControl): ValidationErrors | null;
|
4907 | /**
|
4908 | * @description
|
4909 | * Registers a callback function to call when the validator inputs change.
|
4910 | *
|
4911 | * @param fn The callback function
|
4912 | */
|
4913 | registerOnValidatorChange?(fn: () => void): void;
|
4914 | }
|
4915 |
|
4916 | /**
|
4917 | * The union of all validator types that can be accepted by a ControlConfig.
|
4918 | */
|
4919 | declare type ValidatorConfig = ValidatorFn | AsyncValidatorFn | ValidatorFn[] | AsyncValidatorFn[];
|
4920 |
|
4921 | /**
|
4922 | * @description
|
4923 | * A function that receives a control and synchronously returns a map of
|
4924 | * validation errors if present, otherwise null.
|
4925 | *
|
4926 | * @publicApi
|
4927 | */
|
4928 | export declare interface ValidatorFn {
|
4929 | (control: AbstractControl): ValidationErrors | null;
|
4930 | }
|
4931 |
|
4932 | /**
|
4933 | * @description
|
4934 | * Provides a set of built-in validators that can be used by form controls.
|
4935 | *
|
4936 | * A validator is a function that processes a `FormControl` or collection of
|
4937 | * controls and returns an error map or null. A null map means that validation has passed.
|
4938 | *
|
4939 | * @see [Form Validation](guide/forms/form-validation)
|
4940 | *
|
4941 | * @publicApi
|
4942 | */
|
4943 | export declare class Validators {
|
4944 | /**
|
4945 | * @description
|
4946 | * Validator that requires the control's value to be greater than or equal to the provided number.
|
4947 | *
|
4948 | * @usageNotes
|
4949 | *
|
4950 | * ### Validate against a minimum of 3
|
4951 | *
|
4952 | * ```typescript
|
4953 | * const control = new FormControl(2, Validators.min(3));
|
4954 | *
|
4955 | * console.log(control.errors); // {min: {min: 3, actual: 2}}
|
4956 | * ```
|
4957 | *
|
4958 | * @returns A validator function that returns an error map with the
|
4959 | * `min` property if the validation check fails, otherwise `null`.
|
4960 | *
|
4961 | * @see {@link updateValueAndValidity()}
|
4962 | *
|
4963 | */
|
4964 | static min(min: number): ValidatorFn;
|
4965 | /**
|
4966 | * @description
|
4967 | * Validator that requires the control's value to be less than or equal to the provided number.
|
4968 | *
|
4969 | * @usageNotes
|
4970 | *
|
4971 | * ### Validate against a maximum of 15
|
4972 | *
|
4973 | * ```typescript
|
4974 | * const control = new FormControl(16, Validators.max(15));
|
4975 | *
|
4976 | * console.log(control.errors); // {max: {max: 15, actual: 16}}
|
4977 | * ```
|
4978 | *
|
4979 | * @returns A validator function that returns an error map with the
|
4980 | * `max` property if the validation check fails, otherwise `null`.
|
4981 | *
|
4982 | * @see {@link updateValueAndValidity()}
|
4983 | *
|
4984 | */
|
4985 | static max(max: number): ValidatorFn;
|
4986 | /**
|
4987 | * @description
|
4988 | * Validator that requires the control have a non-empty value.
|
4989 | *
|
4990 | * @usageNotes
|
4991 | *
|
4992 | * ### Validate that the field is non-empty
|
4993 | *
|
4994 | * ```typescript
|
4995 | * const control = new FormControl('', Validators.required);
|
4996 | *
|
4997 | * console.log(control.errors); // {required: true}
|
4998 | * ```
|
4999 | *
|
5000 | * @returns An error map with the `required` property
|
5001 | * if the validation check fails, otherwise `null`.
|
5002 | *
|
5003 | * @see {@link updateValueAndValidity()}
|
5004 | *
|
5005 | */
|
5006 | static required(control: AbstractControl): ValidationErrors | null;
|
5007 | /**
|
5008 | * @description
|
5009 | * Validator that requires the control's value be true. This validator is commonly
|
5010 | * used for required checkboxes.
|
5011 | *
|
5012 | * @usageNotes
|
5013 | *
|
5014 | * ### Validate that the field value is true
|
5015 | *
|
5016 | * ```typescript
|
5017 | * const control = new FormControl('some value', Validators.requiredTrue);
|
5018 | *
|
5019 | * console.log(control.errors); // {required: true}
|
5020 | * ```
|
5021 | *
|
5022 | * @returns An error map that contains the `required` property
|
5023 | * set to `true` if the validation check fails, otherwise `null`.
|
5024 | *
|
5025 | * @see {@link updateValueAndValidity()}
|
5026 | *
|
5027 | */
|
5028 | static requiredTrue(control: AbstractControl): ValidationErrors | null;
|
5029 | /**
|
5030 | * @description
|
5031 | * Validator that requires the control's value pass an email validation test.
|
5032 | *
|
5033 | * Tests the value using a [regular
|
5034 | * expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
|
5035 | * pattern suitable for common use cases. The pattern is based on the definition of a valid email
|
5036 | * address in the [WHATWG HTML
|
5037 | * specification](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address) with
|
5038 | * some enhancements to incorporate more RFC rules (such as rules related to domain names and the
|
5039 | * lengths of different parts of the address).
|
5040 | *
|
5041 | * The differences from the WHATWG version include:
|
5042 | * - Disallow `local-part` (the part before the `@` symbol) to begin or end with a period (`.`).
|
5043 | * - Disallow `local-part` to be longer than 64 characters.
|
5044 | * - Disallow the whole address to be longer than 254 characters.
|
5045 | *
|
5046 | * If this pattern does not satisfy your business needs, you can use `Validators.pattern()` to
|
5047 | * validate the value against a different pattern.
|
5048 | *
|
5049 | * @usageNotes
|
5050 | *
|
5051 | * ### Validate that the field matches a valid email pattern
|
5052 | *
|
5053 | * ```typescript
|
5054 | * const control = new FormControl('bad@', Validators.email);
|
5055 | *
|
5056 | * console.log(control.errors); // {email: true}
|
5057 | * ```
|
5058 | *
|
5059 | * @returns An error map with the `email` property
|
5060 | * if the validation check fails, otherwise `null`.
|
5061 | *
|
5062 | * @see {@link updateValueAndValidity()}
|
5063 | *
|
5064 | */
|
5065 | static email(control: AbstractControl): ValidationErrors | null;
|
5066 | /**
|
5067 | * @description
|
5068 | * Validator that requires the length of the control's value to be greater than or equal
|
5069 | * to the provided minimum length. This validator is also provided by default if you use the
|
5070 | * the HTML5 `minlength` attribute. Note that the `minLength` validator is intended to be used
|
5071 | * only for types that have a numeric `length` property, such as strings or arrays. The
|
5072 | * `minLength` validator logic is also not invoked for values when their `length` property is 0
|
5073 | * (for example in case of an empty string or an empty array), to support optional controls. You
|
5074 | * can use the standard `required` validator if empty values should not be considered valid.
|
5075 | *
|
5076 | * @usageNotes
|
5077 | *
|
5078 | * ### Validate that the field has a minimum of 3 characters
|
5079 | *
|
5080 | * ```typescript
|
5081 | * const control = new FormControl('ng', Validators.minLength(3));
|
5082 | *
|
5083 | * console.log(control.errors); // {minlength: {requiredLength: 3, actualLength: 2}}
|
5084 | * ```
|
5085 | *
|
5086 | * ```html
|
5087 | * <input minlength="5">
|
5088 | * ```
|
5089 | *
|
5090 | * @returns A validator function that returns an error map with the
|
5091 | * `minlength` property if the validation check fails, otherwise `null`.
|
5092 | *
|
5093 | * @see {@link updateValueAndValidity()}
|
5094 | *
|
5095 | */
|
5096 | static minLength(minLength: number): ValidatorFn;
|
5097 | /**
|
5098 | * @description
|
5099 | * Validator that requires the length of the control's value to be less than or equal
|
5100 | * to the provided maximum length. This validator is also provided by default if you use the
|
5101 | * the HTML5 `maxlength` attribute. Note that the `maxLength` validator is intended to be used
|
5102 | * only for types that have a numeric `length` property, such as strings or arrays.
|
5103 | *
|
5104 | * @usageNotes
|
5105 | *
|
5106 | * ### Validate that the field has maximum of 5 characters
|
5107 | *
|
5108 | * ```typescript
|
5109 | * const control = new FormControl('Angular', Validators.maxLength(5));
|
5110 | *
|
5111 | * console.log(control.errors); // {maxlength: {requiredLength: 5, actualLength: 7}}
|
5112 | * ```
|
5113 | *
|
5114 | * ```html
|
5115 | * <input maxlength="5">
|
5116 | * ```
|
5117 | *
|
5118 | * @returns A validator function that returns an error map with the
|
5119 | * `maxlength` property if the validation check fails, otherwise `null`.
|
5120 | *
|
5121 | * @see {@link updateValueAndValidity()}
|
5122 | *
|
5123 | */
|
5124 | static maxLength(maxLength: number): ValidatorFn;
|
5125 | /**
|
5126 | * @description
|
5127 | * Validator that requires the control's value to match a regex pattern. This validator is also
|
5128 | * provided by default if you use the HTML5 `pattern` attribute.
|
5129 | *
|
5130 | * @usageNotes
|
5131 | *
|
5132 | * ### Validate that the field only contains letters or spaces
|
5133 | *
|
5134 | * ```typescript
|
5135 | * const control = new FormControl('1', Validators.pattern('[a-zA-Z ]*'));
|
5136 | *
|
5137 | * console.log(control.errors); // {pattern: {requiredPattern: '^[a-zA-Z ]*$', actualValue: '1'}}
|
5138 | * ```
|
5139 | *
|
5140 | * ```html
|
5141 | * <input pattern="[a-zA-Z ]*">
|
5142 | * ```
|
5143 | *
|
5144 | * ### Pattern matching with the global or sticky flag
|
5145 | *
|
5146 | * `RegExp` objects created with the `g` or `y` flags that are passed into `Validators.pattern`
|
5147 | * can produce different results on the same input when validations are run consecutively. This is
|
5148 | * due to how the behavior of `RegExp.prototype.test` is
|
5149 | * specified in [ECMA-262](https://tc39.es/ecma262/#sec-regexpbuiltinexec)
|
5150 | * (`RegExp` preserves the index of the last match when the global or sticky flag is used).
|
5151 | * Due to this behavior, it is recommended that when using
|
5152 | * `Validators.pattern` you **do not** pass in a `RegExp` object with either the global or sticky
|
5153 | * flag enabled.
|
5154 | *
|
5155 | * ```typescript
|
5156 | * // Not recommended (since the `g` flag is used)
|
5157 | * const controlOne = new FormControl('1', Validators.pattern(/foo/g));
|
5158 | *
|
5159 | * // Good
|
5160 | * const controlTwo = new FormControl('1', Validators.pattern(/foo/));
|
5161 | * ```
|
5162 | *
|
5163 | * @param pattern A regular expression to be used as is to test the values, or a string.
|
5164 | * If a string is passed, the `^` character is prepended and the `$` character is
|
5165 | * appended to the provided string (if not already present), and the resulting regular
|
5166 | * expression is used to test the values.
|
5167 | *
|
5168 | * @returns A validator function that returns an error map with the
|
5169 | * `pattern` property if the validation check fails, otherwise `null`.
|
5170 | *
|
5171 | * @see {@link updateValueAndValidity()}
|
5172 | *
|
5173 | */
|
5174 | static pattern(pattern: string | RegExp): ValidatorFn;
|
5175 | /**
|
5176 | * @description
|
5177 | * Validator that performs no operation.
|
5178 | *
|
5179 | * @see {@link updateValueAndValidity()}
|
5180 | *
|
5181 | */
|
5182 | static nullValidator(control: AbstractControl): ValidationErrors | null;
|
5183 | /**
|
5184 | * @description
|
5185 | * Compose multiple validators into a single function that returns the union
|
5186 | * of the individual error maps for the provided control.
|
5187 | *
|
5188 | * @returns A validator function that returns an error map with the
|
5189 | * merged error maps of the validators if the validation check fails, otherwise `null`.
|
5190 | *
|
5191 | * @see {@link updateValueAndValidity()}
|
5192 | *
|
5193 | */
|
5194 | static compose(validators: null): null;
|
5195 | static compose(validators: (ValidatorFn | null | undefined)[]): ValidatorFn | null;
|
5196 | /**
|
5197 | * @description
|
5198 | * Compose multiple async validators into a single function that returns the union
|
5199 | * of the individual error objects for the provided control.
|
5200 | *
|
5201 | * @returns A validator function that returns an error map with the
|
5202 | * merged error objects of the async validators if the validation check fails, otherwise `null`.
|
5203 | *
|
5204 | * @see {@link updateValueAndValidity()}
|
5205 | *
|
5206 | */
|
5207 | static composeAsync(validators: (AsyncValidatorFn | null)[]): AsyncValidatorFn | null;
|
5208 | }
|
5209 |
|
5210 | /**
|
5211 | * Event fired when the value of a control changes.
|
5212 | *
|
5213 | * @publicApi
|
5214 | */
|
5215 | export declare class ValueChangeEvent<T> extends ControlEvent<T> {
|
5216 | readonly value: T;
|
5217 | readonly source: AbstractControl;
|
5218 | constructor(value: T, source: AbstractControl);
|
5219 | }
|
5220 |
|
5221 | /**
|
5222 | * @publicApi
|
5223 | */
|
5224 | export declare const VERSION: Version;
|
5225 |
|
5226 | /**
|
5227 | * CoerceStrArrToNumArr accepts an array of strings, and converts any numeric string to a number.
|
5228 | */
|
5229 | export declare type ɵCoerceStrArrToNumArr<S> = S extends [infer Head, ...infer Tail] ? Head extends `${number}` ? [number, ...ɵCoerceStrArrToNumArr<Tail>] : [Head, ...ɵCoerceStrArrToNumArr<Tail>] : [];
|
5230 |
|
5231 | /**
|
5232 | * FormBuilder accepts values in various container shapes, as well as raw values.
|
5233 | * Element returns the appropriate corresponding model class, given the container T.
|
5234 | * The flag N, if not never, makes the resulting `FormControl` have N in its type.
|
5235 | */
|
5236 | export declare type ɵElement<T, N extends null> = [
|
5237 | T
|
5238 | ] extends [FormControl<infer U>] ? FormControl<U> : [
|
5239 | T
|
5240 | ] extends [FormControl<infer U> | undefined] ? FormControl<U> : [
|
5241 | T
|
5242 | ] extends [FormGroup<infer U>] ? FormGroup<U> : [
|
5243 | T
|
5244 | ] extends [FormGroup<infer U> | undefined] ? FormGroup<U> : [
|
5245 | T
|
5246 | ] extends [FormRecord<infer U>] ? FormRecord<U> : [
|
5247 | T
|
5248 | ] extends [FormRecord<infer U> | undefined] ? FormRecord<U> : [
|
5249 | T
|
5250 | ] extends [FormArray<infer U>] ? FormArray<U> : [
|
5251 | T
|
5252 | ] extends [FormArray<infer U> | undefined] ? FormArray<U> : [
|
5253 | T
|
5254 | ] extends [AbstractControl<infer U>] ? AbstractControl<U> : [
|
5255 | T
|
5256 | ] extends [AbstractControl<infer U> | undefined] ? AbstractControl<U> : [
|
5257 | T
|
5258 | ] extends [FormControlState<infer U>] ? FormControl<U | N> : [
|
5259 | T
|
5260 | ] extends [PermissiveControlConfig<infer U>] ? FormControl<Exclude<U, ValidatorConfig | PermissiveAbstractControlOptions> | N> : FormControl<T | N>;
|
5261 |
|
5262 | /**
|
5263 | * FormArrayRawValue extracts the type of `.getRawValue()` from a FormArray's element type, and
|
5264 | * wraps it in an array. The untyped case falls back to any[].
|
5265 | *
|
5266 | * Angular uses this type internally to support Typed Forms; do not use it directly.
|
5267 | */
|
5268 | export declare type ɵFormArrayRawValue<T extends AbstractControl<any>> = ɵTypedOrUntyped<T, Array<ɵRawValue<T>>, any[]>;
|
5269 |
|
5270 | /**
|
5271 | * FormArrayValue extracts the type of `.value` from a FormArray's element type, and wraps it in an
|
5272 | * array.
|
5273 | *
|
5274 | * Angular uses this type internally to support Typed Forms; do not use it directly. The untyped
|
5275 | * case falls back to any[].
|
5276 | */
|
5277 | export declare type ɵFormArrayValue<T extends AbstractControl<any>> = ɵTypedOrUntyped<T, Array<ɵValue<T>>, any[]>;
|
5278 |
|
5279 | /**
|
5280 | * Various available constructors for `FormControl`.
|
5281 | * Do not use this interface directly. Instead, use `FormControl`:
|
5282 | * ```
|
5283 | * const fc = new FormControl('foo');
|
5284 | * ```
|
5285 | * This symbol is prefixed with ɵ to make plain that it is an internal symbol.
|
5286 | */
|
5287 | export declare interface ɵFormControlCtor {
|
5288 | /**
|
5289 | * Construct a FormControl with no initial value or validators.
|
5290 | */
|
5291 | new (): FormControl<any>;
|
5292 | /**
|
5293 | * Creates a new `FormControl` instance.
|
5294 | *
|
5295 | * @param formState Initializes the control with an initial value,
|
5296 | * or an object that defines the initial value and disabled state.
|
5297 | *
|
5298 | * @param validatorOrOpts A synchronous validator function, or an array of
|
5299 | * such functions, or a `FormControlOptions` object that contains validation functions
|
5300 | * and a validation trigger.
|
5301 | *
|
5302 | * @param asyncValidator A single async validator or array of async validator functions
|
5303 | */
|
5304 | new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
|
5305 | nonNullable: true;
|
5306 | }): FormControl<T>;
|
5307 | /**
|
5308 | * @deprecated Use `nonNullable` instead.
|
5309 | */
|
5310 | new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions & {
|
5311 | initialValueIsDefault: true;
|
5312 | }): FormControl<T>;
|
5313 | /**
|
5314 | * @deprecated When passing an `options` argument, the `asyncValidator` argument has no effect.
|
5315 | */
|
5316 | new <T = any>(value: FormControlState<T> | T, opts: FormControlOptions, asyncValidator: AsyncValidatorFn | AsyncValidatorFn[]): FormControl<T | null>;
|
5317 | new <T = any>(value: FormControlState<T> | T, validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl<T | null>;
|
5318 | /**
|
5319 | * The presence of an explicit `prototype` property provides backwards-compatibility for apps that
|
5320 | * manually inspect the prototype chain.
|
5321 | */
|
5322 | prototype: FormControl<any>;
|
5323 | }
|
5324 |
|
5325 | /**
|
5326 | * FormGroupRawValue extracts the type of `.getRawValue()` from a FormGroup's inner object type. The
|
5327 | * untyped case falls back to {[key: string]: any}.
|
5328 | *
|
5329 | * Angular uses this type internally to support Typed Forms; do not use it directly.
|
5330 | *
|
5331 | * For internal use only.
|
5332 | */
|
5333 | export declare type ɵFormGroupRawValue<T extends {
|
5334 | [K in keyof T]?: AbstractControl<any>;
|
5335 | }> = ɵTypedOrUntyped<T, {
|
5336 | [K in keyof T]: ɵRawValue<T[K]>;
|
5337 | }, {
|
5338 | [key: string]: any;
|
5339 | }>;
|
5340 |
|
5341 | /**
|
5342 | * FormGroupValue extracts the type of `.value` from a FormGroup's inner object type. The untyped
|
5343 | * case falls back to {[key: string]: any}.
|
5344 | *
|
5345 | * Angular uses this type internally to support Typed Forms; do not use it directly.
|
5346 | *
|
5347 | * For internal use only.
|
5348 | */
|
5349 | export declare type ɵFormGroupValue<T extends {
|
5350 | [K in keyof T]?: AbstractControl<any>;
|
5351 | }> = ɵTypedOrUntyped<T, Partial<{
|
5352 | [K in keyof T]: ɵValue<T[K]>;
|
5353 | }>, {
|
5354 | [key: string]: any;
|
5355 | }>;
|
5356 |
|
5357 | /**
|
5358 | * GetProperty takes a type T and some property names or indices K.
|
5359 | * If K is a dot-separated string, it is tokenized into an array before proceeding.
|
5360 | * Then, the type of the nested property at K is computed: T[K[0]][K[1]][K[2]]...
|
5361 | * This works with both objects, which are indexed by property name, and arrays, which are indexed
|
5362 | * numerically.
|
5363 | *
|
5364 | * For internal use only.
|
5365 | */
|
5366 | export declare type ɵGetProperty<T, K> = K extends string ? ɵGetProperty<T, ɵCoerceStrArrToNumArr<ɵTokenize<K, '.'>>> : ɵWriteable<K> extends Array<string | number> ? ɵNavigate<T, ɵWriteable<K>> : any;
|
5367 |
|
5368 | /**
|
5369 | * Internal module used for sharing directives between FormsModule and ReactiveFormsModule
|
5370 | */
|
5371 | export declare class ɵInternalFormsSharedModule {
|
5372 | static ɵfac: i0.ɵɵFactoryDeclaration<ɵInternalFormsSharedModule, never>;
|
5373 | static ɵmod: i0.ɵɵNgModuleDeclaration<ɵInternalFormsSharedModule, [typeof i1.ɵNgNoValidate, typeof i2.NgSelectOption, typeof i3.ɵNgSelectMultipleOption, typeof i4.DefaultValueAccessor, typeof i5.NumberValueAccessor, typeof i6.RangeValueAccessor, typeof i7.CheckboxControlValueAccessor, typeof i2.SelectControlValueAccessor, typeof i3.SelectMultipleControlValueAccessor, typeof i8.RadioControlValueAccessor, typeof i9.NgControlStatus, typeof i9.NgControlStatusGroup, typeof i10.RequiredValidator, typeof i10.MinLengthValidator, typeof i10.MaxLengthValidator, typeof i10.PatternValidator, typeof i10.CheckboxRequiredValidator, typeof i10.EmailValidator, typeof i10.MinValidator, typeof i10.MaxValidator], never, [typeof i1.ɵNgNoValidate, typeof i2.NgSelectOption, typeof i3.ɵNgSelectMultipleOption, typeof i4.DefaultValueAccessor, typeof i5.NumberValueAccessor, typeof i6.RangeValueAccessor, typeof i7.CheckboxControlValueAccessor, typeof i2.SelectControlValueAccessor, typeof i3.SelectMultipleControlValueAccessor, typeof i8.RadioControlValueAccessor, typeof i9.NgControlStatus, typeof i9.NgControlStatusGroup, typeof i10.RequiredValidator, typeof i10.MinLengthValidator, typeof i10.MaxLengthValidator, typeof i10.PatternValidator, typeof i10.CheckboxRequiredValidator, typeof i10.EmailValidator, typeof i10.MinValidator, typeof i10.MaxValidator]>;
|
5374 | static ɵinj: i0.ɵɵInjectorDeclaration<ɵInternalFormsSharedModule>;
|
5375 | }
|
5376 |
|
5377 | declare type ɵIsAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
5378 |
|
5379 | /**
|
5380 | * Navigate takes a type T and an array K, and returns the type of T[K[0]][K[1]][K[2]]...
|
5381 | */
|
5382 | export declare type ɵNavigate<T, K extends Array<string | number>> = T extends object ? K extends [infer Head, ...infer Tail] ? Head extends keyof T ? Tail extends (string | number)[] ? [] extends Tail ? T[Head] : ɵNavigate<T[Head], Tail> : any : never : any : any;
|
5383 |
|
5384 | /**
|
5385 | * @description
|
5386 | *
|
5387 | * Adds `novalidate` attribute to all forms by default.
|
5388 | *
|
5389 | * `novalidate` is used to disable browser's native form validation.
|
5390 | *
|
5391 | * If you want to use native validation with Angular forms, just add `ngNativeValidate` attribute:
|
5392 | *
|
5393 | * ```
|
5394 | * <form ngNativeValidate></form>
|
5395 | * ```
|
5396 | *
|
5397 | * @publicApi
|
5398 | * @ngModule ReactiveFormsModule
|
5399 | * @ngModule FormsModule
|
5400 | */
|
5401 | export declare class ɵNgNoValidate {
|
5402 | static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgNoValidate, never>;
|
5403 | static ɵdir: i0.ɵɵDirectiveDeclaration<ɵNgNoValidate, "form:not([ngNoForm]):not([ngNativeValidate])", never, {}, {}, never, never, false, never>;
|
5404 | }
|
5405 |
|
5406 | /**
|
5407 | * @description
|
5408 | * Marks `<option>` as dynamic, so Angular can be notified when options change.
|
5409 | *
|
5410 | * @see {@link SelectMultipleControlValueAccessor}
|
5411 | *
|
5412 | * @ngModule ReactiveFormsModule
|
5413 | * @ngModule FormsModule
|
5414 | * @publicApi
|
5415 | */
|
5416 | export declare class ɵNgSelectMultipleOption implements OnDestroy {
|
5417 | private _element;
|
5418 | private _renderer;
|
5419 | private _select;
|
5420 | id: string;
|
5421 | constructor(_element: ElementRef, _renderer: Renderer2, _select: SelectMultipleControlValueAccessor);
|
5422 | /**
|
5423 | * @description
|
5424 | * Tracks the value bound to the option element. Unlike the value binding,
|
5425 | * ngValue supports binding to objects.
|
5426 | */
|
5427 | set ngValue(value: any);
|
5428 | /**
|
5429 | * @description
|
5430 | * Tracks simple string values bound to the option element.
|
5431 | * For objects, use the `ngValue` input binding.
|
5432 | */
|
5433 | set value(value: any);
|
5434 | /** @nodoc */
|
5435 | ngOnDestroy(): void;
|
5436 | static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgSelectMultipleOption, [null, null, { optional: true; host: true; }]>;
|
5437 | static ɵdir: i0.ɵɵDirectiveDeclaration<ɵNgSelectMultipleOption, "option", never, { "ngValue": { "alias": "ngValue"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, false, never>;
|
5438 | }
|
5439 |
|
5440 | /**
|
5441 | * OptionalKeys returns the union of all optional keys in the object.
|
5442 | *
|
5443 | * Angular uses this type internally to support Typed Forms; do not use it directly.
|
5444 | */
|
5445 | export declare type ɵOptionalKeys<T> = {
|
5446 | [K in keyof T]-?: undefined extends T[K] ? K : never;
|
5447 | }[keyof T];
|
5448 |
|
5449 | /**
|
5450 | * RawValue gives the raw value type corresponding to a control type.
|
5451 | *
|
5452 | * Note that the resulting type will follow the same rules as `.getRawValue()` on your control,
|
5453 | * group, or array. This means that all controls inside a group will be required, not optional,
|
5454 | * regardless of their disabled state.
|
5455 | *
|
5456 | * You may also wish to use {@link ɵValue}, which will have `undefined` in group keys (which can be
|
5457 | * disabled).
|
5458 | *
|
5459 | * @usageNotes
|
5460 | *
|
5461 | * ### `FormGroup` raw value type
|
5462 | *
|
5463 | * Imagine you have an interface defining the controls in your group. You can extract the shape of
|
5464 | * the raw values as follows:
|
5465 | *
|
5466 | * ```ts
|
5467 | * interface PartyFormControls {
|
5468 | * address: FormControl<string>;
|
5469 | * }
|
5470 | *
|
5471 | * // RawValue operates on controls; the object must be wrapped in a FormGroup.
|
5472 | * type PartyFormValues = RawValue<FormGroup<PartyFormControls>>;
|
5473 | * ```
|
5474 | *
|
5475 | * The resulting type is `{address: string}`. (Note the absence of `undefined`.)
|
5476 | *
|
5477 | * **Internal: not for public use.**
|
5478 | */
|
5479 | export declare type ɵRawValue<T extends AbstractControl | undefined> = T extends AbstractControl<any, any> ? T['setValue'] extends (v: infer R) => void ? R : never : never;
|
5480 |
|
5481 | /**
|
5482 | * Tokenize splits a string literal S by a delimiter D.
|
5483 | */
|
5484 | export declare type ɵTokenize<S extends string, D extends string> = string extends S ? string[] : S extends `${infer T}${D}${infer U}` ? [T, ...ɵTokenize<U, D>] : [S];
|
5485 |
|
5486 | /**
|
5487 | * `TypedOrUntyped` allows one of two different types to be selected, depending on whether the Forms
|
5488 | * class it's applied to is typed or not.
|
5489 | *
|
5490 | * This is for internal Angular usage to support typed forms; do not directly use it.
|
5491 | */
|
5492 | export declare type ɵTypedOrUntyped<T, Typed, Untyped> = ɵIsAny<T, Untyped, Typed>;
|
5493 |
|
5494 | /**
|
5495 | * Value gives the value type corresponding to a control type.
|
5496 | *
|
5497 | * Note that the resulting type will follow the same rules as `.value` on your control, group, or
|
5498 | * array, including `undefined` for each group element which might be disabled.
|
5499 | *
|
5500 | * If you are trying to extract a value type for a data model, you probably want {@link RawValue},
|
5501 | * which will not have `undefined` in group keys.
|
5502 | *
|
5503 | * @usageNotes
|
5504 | *
|
5505 | * ### `FormControl` value type
|
5506 | *
|
5507 | * You can extract the value type of a single control:
|
5508 | *
|
5509 | * ```ts
|
5510 | * type NameControl = FormControl<string>;
|
5511 | * type NameValue = Value<NameControl>;
|
5512 | * ```
|
5513 | *
|
5514 | * The resulting type is `string`.
|
5515 | *
|
5516 | * ### `FormGroup` value type
|
5517 | *
|
5518 | * Imagine you have an interface defining the controls in your group. You can extract the shape of
|
5519 | * the values as follows:
|
5520 | *
|
5521 | * ```ts
|
5522 | * interface PartyFormControls {
|
5523 | * address: FormControl<string>;
|
5524 | * }
|
5525 | *
|
5526 | * // Value operates on controls; the object must be wrapped in a FormGroup.
|
5527 | * type PartyFormValues = Value<FormGroup<PartyFormControls>>;
|
5528 | * ```
|
5529 | *
|
5530 | * The resulting type is `{address: string|undefined}`.
|
5531 | *
|
5532 | * ### `FormArray` value type
|
5533 | *
|
5534 | * You can extract values from FormArrays as well:
|
5535 | *
|
5536 | * ```ts
|
5537 | * type GuestNamesControls = FormArray<FormControl<string>>;
|
5538 | *
|
5539 | * type NamesValues = Value<GuestNamesControls>;
|
5540 | * ```
|
5541 | *
|
5542 | * The resulting type is `string[]`.
|
5543 | *
|
5544 | * **Internal: not for public use.**
|
5545 | */
|
5546 | export declare type ɵValue<T extends AbstractControl | undefined> = T extends AbstractControl<any, any> ? T['value'] : never;
|
5547 |
|
5548 | /**
|
5549 | * ɵWriteable removes readonly from all keys.
|
5550 | */
|
5551 | export declare type ɵWriteable<T> = {
|
5552 | -readonly [P in keyof T]: T[P];
|
5553 | };
|
5554 |
|
5555 | export { }
|
5556 |
|
\ | No newline at end of file |