feat(forms): add default updateOn values for groups and arrays (#18536)

This commit adds support for setting default `updateOn` values
in `FormGroups` and `FormArrays`. If you set `updateOn` to
’blur’` at the group level, all child controls will default to `’blur’`,
unless the child has explicitly specified a different `updateOn` value.

```
const c = new FormGroup({
   one: new FormControl()
}, {updateOn: blur});
```

 It's worth noting that parent groups will always update their value and
validity immediately upon value/validity updates from children. In other
words, if a group is set to update on blur and its children are individually
set to update on change, the group will still update on change with its
children; its default value will simply not be used.
This commit is contained in:
Kara
2017-08-09 15:41:53 -07:00
committed by Victor Berchet
parent dca50deae4
commit ff5c58be6b
6 changed files with 302 additions and 21 deletions

View File

@ -150,7 +150,7 @@ export class FormGroupDirective extends ControlContainer implements Form,
_syncPendingControls() {
this.form._syncPendingControls();
this.directives.forEach(dir => {
if (dir.control._updateOn === 'submit') {
if (dir.control.updateOn === 'submit') {
dir.viewToModelUpdate(dir.control._pendingValue);
}
});