I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
In standard HTML/TypeScript, without angular, it's possible to get a HTMLFormElement and call either .sumbit() or .reset() on it to submit it programmatically. If we want to do this in an Angular2 Component, we will need to either:
- have a
@ViewChild('myForm') formElementRef, casting the formElementRef.nativeElement to HtmlFormElement and then call .submit() on it
- have a hidden
input type="sumbit" (or similar), again do a @ViewChild on it and trigger it programmatically.
Note that in the case of .reset() this is very well supported and documented.
Expected behavior
To be able to trigger the .submit() operation directly from an FormGroup/FormArray or even an NgForm would be really helpful.
There are cases where, for practical UI/UX reasons the submit button cannot be in the <form> element itself. Although this is far from ideal, it's still something that can be and is done.
Minimal reproduction of the problem with instructions
`<button #submit>Submit!
[...]`
Then try to submit the form without using an ElementRef or a hidden submit inside the <form>.
What is the motivation / use case for changing the behavior?
Some UIs will require us to have the submit element outside of the <form>, or to submit a form relying on different mechanism/conditions (e.g., time triggered for a game-like UI).
Environment
Angular version: 5.1.0-beta.1
I'm submitting a...
Current behavior
In standard HTML/TypeScript, without angular, it's possible to get a HTMLFormElement and call either
.sumbit()or.reset()on it to submit it programmatically. If we want to do this in an Angular2 Component, we will need to either:@ViewChild('myForm') formElementRef, casting theformElementRef.nativeElementtoHtmlFormElementand then call.submit()on itinput type="sumbit"(or similar), again do a@ViewChildon it and trigger it programmatically.Note that in the case of
.reset()this is very well supported and documented.Expected behavior
To be able to trigger the
.submit()operation directly from anFormGroup/FormArrayor even anNgFormwould be really helpful.There are cases where, for practical UI/UX reasons the submit button cannot be in the
<form>element itself. Although this is far from ideal, it's still something that can be and is done.Minimal reproduction of the problem with instructions
`<button #submit>Submit!
[...]`Then try to submit the form without using an
ElementRefor a hidden submit inside the<form>.What is the motivation / use case for changing the behavior?
Some UIs will require us to have the submit element outside of the
<form>, or to submit a form relying on different mechanism/conditions (e.g., time triggered for a game-like UI).Environment