feat(forms): add updateOn and ngFormOptions to NgForm

This commit introduces a new Input property called
`ngFormOptions` to the `NgForm` directive. You can use it
to set default `updateOn` values for all the form's child
controls. This default will be used unless the child has
already explicitly set its own `updateOn` value in
`ngModelOptions`.

Potential values: `change` | `blur` | `submit`

```html
<form [ngFormOptions]="{updateOn: blur}">
  <input name="one" ngModel>  <!-- will update on blur-->
</form>
```

For more context, see [#18577](https://github.com/angular/angular/pull/18577).
This commit is contained in:
Kara Erickson
2017-08-08 14:37:29 -07:00
committed by Hans
parent 43226cb93d
commit 0d45828460
3 changed files with 156 additions and 8 deletions

View File

@ -388,7 +388,7 @@ export declare class NgControlStatusGroup extends AbstractControlStatus {
}
/** @stable */
export declare class NgForm extends ControlContainer implements Form {
export declare class NgForm extends ControlContainer implements Form, AfterViewInit {
readonly control: FormGroup;
readonly controls: {
[key: string]: AbstractControl;
@ -396,6 +396,9 @@ export declare class NgForm extends ControlContainer implements Form {
form: FormGroup;
readonly formDirective: Form;
ngSubmit: EventEmitter<{}>;
options: {
updateOn?: FormHooks;
};
readonly path: string[];
readonly submitted: boolean;
constructor(validators: any[], asyncValidators: any[]);
@ -403,6 +406,7 @@ export declare class NgForm extends ControlContainer implements Form {
addFormGroup(dir: NgModelGroup): void;
getControl(dir: NgModel): FormControl;
getFormGroup(dir: NgModelGroup): FormGroup;
ngAfterViewInit(): void;
onReset(): void;
onSubmit($event: Event): boolean;
removeControl(dir: NgModel): void;