feat(forms): add updateOn submit option to FormControls (#18514)

This commit is contained in:
Kara
2017-08-07 15:39:25 -07:00
committed by Victor Berchet
parent 685cc26ab2
commit f69561b2de
4 changed files with 411 additions and 20 deletions

View File

@ -134,6 +134,7 @@ export class FormGroupDirective extends ControlContainer implements Form,
onSubmit($event: Event): boolean {
this._submitted = true;
this._syncPendingControls();
this.ngSubmit.emit($event);
return false;
}
@ -145,6 +146,16 @@ export class FormGroupDirective extends ControlContainer implements Form,
this._submitted = false;
}
/** @internal */
_syncPendingControls() {
this.form._syncPendingControls();
this.directives.forEach(dir => {
if (dir.control._updateOn === 'submit') {
dir.viewToModelUpdate(dir.control._pendingValue);
}
});
}
/** @internal */
_updateDomValue() {
this.directives.forEach(dir => {