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 } from '@angular/core';
|
9
|
import { AbstractControl, FormControl, FormGroup } from '../model';
|
10
|
import { ControlContainer } from './control_container';
|
11
|
import { Form } from './form_interface';
|
12
|
import { NgControl } from './ng_control';
|
13
|
import { NgModel } from './ng_model';
|
14
|
import { NgModelGroup } from './ng_model_group';
|
15
|
export declare const formDirectiveProvider: any;
|
16
|
/**
|
17
|
* @whatItDoes Creates a top-level {@link FormGroup} instance and binds it to a form
|
18
|
* to track aggregate form value and validation status.
|
19
|
*
|
20
|
* @howToUse
|
21
|
*
|
22
|
* As soon as you import the `FormsModule`, this directive becomes active by default on
|
23
|
* all `<form>` tags. You don't need to add a special selector.
|
24
|
*
|
25
|
* You can export the directive into a local template variable using `ngForm` as the key
|
26
|
* (ex: `#myForm="ngForm"`). This is optional, but useful. Many properties from the underlying
|
27
|
* {@link FormGroup} instance are duplicated on the directive itself, so a reference to it
|
28
|
* will give you access to the aggregate value and validity status of the form, as well as
|
29
|
* user interaction properties like `dirty` and `touched`.
|
30
|
*
|
31
|
* To register child controls with the form, you'll want to use {@link NgModel} with a
|
32
|
* `name` attribute. You can also use {@link NgModelGroup} if you'd like to create
|
33
|
* sub-groups within the form.
|
34
|
*
|
35
|
* You can listen to the directive's `ngSubmit` event to be notified when the user has
|
36
|
* triggered a form submission. The `ngSubmit` event will be emitted with the original form
|
37
|
* submission event.
|
38
|
*
|
39
|
* In template driven forms, all `<form>` tags are automatically tagged as `NgForm`.
|
40
|
* If you want to import the `FormsModule` but skip its usage in some forms,
|
41
|
* for example, to use native HTML5 validation, you can add `ngNoForm` and the `<form>`
|
42
|
* tags won't create an `NgForm` directive. In reactive forms, using `ngNoForm` is
|
43
|
* unnecessary because the `<form>` tags are inert. In that case, you would
|
44
|
* refrain from using the `formGroup` directive.
|
45
|
*
|
46
|
* {@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
|
47
|
*
|
48
|
* * **npm package**: `@angular/forms`
|
49
|
*
|
50
|
* * **NgModule**: `FormsModule`
|
51
|
*
|
52
|
* @stable
|
53
|
*/
|
54
|
export declare class NgForm extends ControlContainer implements Form {
|
55
|
private _submitted;
|
56
|
form: FormGroup;
|
57
|
ngSubmit: EventEmitter<{}>;
|
58
|
constructor(validators: any[], asyncValidators: any[]);
|
59
|
readonly submitted: boolean;
|
60
|
readonly formDirective: Form;
|
61
|
readonly control: FormGroup;
|
62
|
readonly path: string[];
|
63
|
readonly controls: {
|
64
|
[key: string]: AbstractControl;
|
65
|
};
|
66
|
addControl(dir: NgModel): void;
|
67
|
getControl(dir: NgModel): FormControl;
|
68
|
removeControl(dir: NgModel): void;
|
69
|
addFormGroup(dir: NgModelGroup): void;
|
70
|
removeFormGroup(dir: NgModelGroup): void;
|
71
|
getFormGroup(dir: NgModelGroup): FormGroup;
|
72
|
updateModel(dir: NgControl, value: any): void;
|
73
|
setValue(value: {
|
74
|
[key: string]: any;
|
75
|
}): void;
|
76
|
onSubmit($event: Event): boolean;
|
77
|
onReset(): void;
|
78
|
resetForm(value?: any): void;
|
79
|
}
|