feat(forms): add the submitted flag to NgForm and NgFormModel directives
Closes #2960 Closes #7449
This commit is contained in:
committed by
Misko Hevery
parent
89f61087c7
commit
420e83a396
@@ -86,6 +86,8 @@ export const formDirectiveProvider: any =
|
||||
exportAs: 'ngForm'
|
||||
})
|
||||
export class NgForm extends ControlContainer implements Form {
|
||||
private _submitted: boolean = false;
|
||||
|
||||
form: ControlGroup;
|
||||
ngSubmit = new EventEmitter();
|
||||
|
||||
@@ -96,6 +98,8 @@ export class NgForm extends ControlContainer implements Form {
|
||||
composeAsyncValidators(asyncValidators));
|
||||
}
|
||||
|
||||
get submitted(): boolean { return this._submitted; }
|
||||
|
||||
get formDirective(): Form { return this; }
|
||||
|
||||
get control(): ControlGroup { return this.form; }
|
||||
@@ -158,6 +162,7 @@ export class NgForm extends ControlContainer implements Form {
|
||||
}
|
||||
|
||||
onSubmit(): boolean {
|
||||
this._submitted = true;
|
||||
ObservableWrapper.callEmit(this.ngSubmit, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ export const formDirectiveProvider: any =
|
||||
})
|
||||
export class NgFormModel extends ControlContainer implements Form,
|
||||
OnChanges {
|
||||
private _submitted: boolean = false;
|
||||
|
||||
form: ControlGroup = null;
|
||||
directives: NgControl[] = [];
|
||||
ngSubmit = new EventEmitter();
|
||||
@@ -131,6 +133,8 @@ export class NgFormModel extends ControlContainer implements Form,
|
||||
this._updateDomValue();
|
||||
}
|
||||
|
||||
get submitted(): boolean { return this._submitted; }
|
||||
|
||||
get formDirective(): Form { return this; }
|
||||
|
||||
get control(): ControlGroup { return this.form; }
|
||||
@@ -166,6 +170,7 @@ export class NgFormModel extends ControlContainer implements Form,
|
||||
}
|
||||
|
||||
onSubmit(): boolean {
|
||||
this._submitted = true;
|
||||
ObservableWrapper.callEmit(this.ngSubmit, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user