Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
9
import { FormControl } from '../../model';
10
import { ControlContainer } from '../control_container';
11
import { ControlValueAccessor } from '../control_value_accessor';
12
import { NgControl } from '../ng_control';
13
import { AsyncValidator, AsyncValidatorFn, Validator, ValidatorFn } from '../validators';
14
export declare const controlNameBinding: any;
15
/**
16
 * @whatItDoes  Syncs a {@link FormControl} in an existing {@link FormGroup} to a form control
17
 * element by name.
18
 *
19
 * In other words, this directive ensures that any values written to the {@link FormControl}
20
 * instance programmatically will be written to the DOM element (model -> view). Conversely,
21
 * any values written to the DOM element through user input will be reflected in the
22
 * {@link FormControl} instance (view -> model).
23
 *
24
 * @howToUse
25
 *
26
 * This directive is designed to be used with a parent {@link FormGroupDirective} (selector:
27
 * `[formGroup]`).
28
 *
29
 * It accepts the string name of the {@link FormControl} instance you want to
30
 * link, and will look for a {@link FormControl} registered with that name in the
31
 * closest {@link FormGroup} or {@link FormArray} above it.
32
 *
33
 * **Access the control**: You can access the {@link FormControl} associated with
34
 * this directive by using the {@link AbstractControl#get get} method.
35
 * Ex: `this.form.get('first');`
36
 *
37
 * **Get value**: the `value` property is always synced and available on the {@link FormControl}.
38
 * See a full list of available properties in {@link AbstractControl}.
39
 *
40
 *  **Set value**: You can set an initial value for the control when instantiating the
41
 *  {@link FormControl}, or you can set it programmatically later using
42
 *  {@link AbstractControl#setValue setValue} or {@link AbstractControl#patchValue patchValue}.
43
 *
44
 * **Listen to value**: If you want to listen to changes in the value of the control, you can
45
 * subscribe to the {@link AbstractControl#valueChanges valueChanges} event.  You can also listen to
46
 * {@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
47
 * re-calculated.
48
 *
49
 * ### Example
50
 *
51
 * In this example, we create form controls for first name and last name.
52
 *
53
 * {@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
54
 *
55
 * To see `formControlName` examples with different form control types, see:
56
 *
57
 * * Radio buttons: {@link RadioControlValueAccessor}
58
 * * Selects: {@link SelectControlValueAccessor}
59
 *
60
 * **npm package**: `@angular/forms`
61
 *
62
 * **NgModule**: {@link ReactiveFormsModule}
63
 *
64
 *  @stable
65
 */
66
export declare class FormControlName extends NgControl implements OnChanges, OnDestroy {
67
    private _added;
68
    name: string;
69
    model: any;
70
    update: EventEmitter<{}>;
71
    isDisabled: boolean;
72
    constructor(parent: ControlContainer, validators: Array<Validator | ValidatorFn>, asyncValidators: Array<AsyncValidator | AsyncValidatorFn>, valueAccessors: ControlValueAccessor[]);
73
    ngOnChanges(changes: SimpleChanges): void;
74
    ngOnDestroy(): void;
75
    viewToModelUpdate(newValue: any): void;
76
    readonly path: string[];
77
    readonly formDirective: any;
78
    readonly validator: ValidatorFn | null;
79
    readonly asyncValidator: AsyncValidatorFn;
80
    readonly control: FormControl;
81
    private _checkParentType();
82
    private _setUpControl();
83
}
(2-2/4)