Angular form: what is the different between submit event and click event? The Next CEO of Stack OverflowDifference between Constructor and ngOnInitWhat is the difference between Promises and Observables?Angular 2 form validation not workingSubmitting form with enter key in Angular unit testAngular 4 ngSubmit not getting values from jquery populated inputsAngular, Get and show submit time after click submit buttonWhy my Angular 5 Parent form not seeing the Child form eventAngular Form does not submit on enter when not focusedAbout concept of ngForm and ngModel in template driven forms in angularSubmit in custom Angular button component does not submit form
What flight has the highest ratio of time difference to flight time?
How to avoid supervisors with prejudiced views?
Why does standard notation not preserve intervals (visually)
A Man With a Stainless Steel Endoskeleton (like The Terminator) Fighting Cloaked Aliens Only He Can See
Easy to read palindrome checker
How to prove a simple equation?
Bartok - Syncopation (1): Meaning of notes in between Grand Staff
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
What did we know about the Kessel run before the prequels?
Is it professional to write unrelated content in an almost-empty email?
Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis
What does "Its cash flow is deeply negative" mean?
How to get from Geneva Airport to Metabief, Doubs, France by public transport?
Is wanting to ask what to write an indication that you need to change your story?
TikZ: How to reverse arrow direction without switching start/end point?
How do I align (1) and (2)?
"misplaced omit" error when >centering columns
Why isn't the Mueller report being released completely and unredacted?
Should I tutor a student who I know has cheated on their homework?
Grabbing quick drinks
When you upcast Blindness/Deafness, do all targets suffer the same effect?
Why didn't Khan get resurrected in the Genesis Explosion?
Are police here, aren't itthey?
How to check if all elements of 1 list are in the *same quantity* and in any order, in the list2?
Angular form: what is the different between submit event and click event?
The Next CEO of Stack OverflowDifference between Constructor and ngOnInitWhat is the difference between Promises and Observables?Angular 2 form validation not workingSubmitting form with enter key in Angular unit testAngular 4 ngSubmit not getting values from jquery populated inputsAngular, Get and show submit time after click submit buttonWhy my Angular 5 Parent form not seeing the Child form eventAngular Form does not submit on enter when not focusedAbout concept of ngForm and ngModel in template driven forms in angularSubmit in custom Angular button component does not submit form
I'm wonder what is the different between form submit event and button click event to do the http post action.
Form submit example:
<form #f="ngForm" (ngSubmit)="onSubmit(f)">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
<button>Submit</button>
</form>
Button click example:
<form #f="ngForm">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
</form>
<div>
<button (click)="onSubmit(f)">Submit</button>
</div>
In background, the handling is just the same.
@ViewChild(NgForm) f: NgForm;
onSubmit()
console.log(this.f);
Anyone know what is the difference?
Thanks a lot.
angular
add a comment |
I'm wonder what is the different between form submit event and button click event to do the http post action.
Form submit example:
<form #f="ngForm" (ngSubmit)="onSubmit(f)">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
<button>Submit</button>
</form>
Button click example:
<form #f="ngForm">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
</form>
<div>
<button (click)="onSubmit(f)">Submit</button>
</div>
In background, the handling is just the same.
@ViewChild(NgForm) f: NgForm;
onSubmit()
console.log(this.f);
Anyone know what is the difference?
Thanks a lot.
angular
add a comment |
I'm wonder what is the different between form submit event and button click event to do the http post action.
Form submit example:
<form #f="ngForm" (ngSubmit)="onSubmit(f)">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
<button>Submit</button>
</form>
Button click example:
<form #f="ngForm">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
</form>
<div>
<button (click)="onSubmit(f)">Submit</button>
</div>
In background, the handling is just the same.
@ViewChild(NgForm) f: NgForm;
onSubmit()
console.log(this.f);
Anyone know what is the difference?
Thanks a lot.
angular
I'm wonder what is the different between form submit event and button click event to do the http post action.
Form submit example:
<form #f="ngForm" (ngSubmit)="onSubmit(f)">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
<button>Submit</button>
</form>
Button click example:
<form #f="ngForm">
<input name="first" ngModel required #first="ngModel">
<input name="last" ngModel>
</form>
<div>
<button (click)="onSubmit(f)">Submit</button>
</div>
In background, the handling is just the same.
@ViewChild(NgForm) f: NgForm;
onSubmit()
console.log(this.f);
Anyone know what is the difference?
Thanks a lot.
angular
angular
asked Mar 8 at 15:28
AliAli
31
31
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The difference is they are two different events registered to different elements in the DOM.
The submit event fires on the
<form>
element itself, and not on any<button>
.The submit event only fires when the user clicks a submit button
By default your submit button has a type of type="submit"
On the other hand the click event is fired when the user clicks on an element, in this case your button.
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
add a comment |
One of the differences that i know so far, is that if you are inside a ngForm
and if you have a (ngSubmit)
event, the function that is linked to this event will be executed if you press ENTER key.
This is helpfull to go through forms quickly, without touching the mouse.
There are more info on the subject at this address
https://angular.io/guide/reactive-forms
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
add a comment |
There is no flagrant difference between the two. The answer made by @HMarteau is inaccurate however, as you can use the 'Enter' button to submit an Angular form whether using the ngSubmit
or the click
event.
The main difference is that Angular's ngSubmit
allows you to use some powerful built in properties such as required
, max-length
, etc., used for validation, which you might not be able to use in the case of click
.
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066310%2fangular-form-what-is-the-different-between-submit-event-and-click-event%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The difference is they are two different events registered to different elements in the DOM.
The submit event fires on the
<form>
element itself, and not on any<button>
.The submit event only fires when the user clicks a submit button
By default your submit button has a type of type="submit"
On the other hand the click event is fired when the user clicks on an element, in this case your button.
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
add a comment |
The difference is they are two different events registered to different elements in the DOM.
The submit event fires on the
<form>
element itself, and not on any<button>
.The submit event only fires when the user clicks a submit button
By default your submit button has a type of type="submit"
On the other hand the click event is fired when the user clicks on an element, in this case your button.
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
add a comment |
The difference is they are two different events registered to different elements in the DOM.
The submit event fires on the
<form>
element itself, and not on any<button>
.The submit event only fires when the user clicks a submit button
By default your submit button has a type of type="submit"
On the other hand the click event is fired when the user clicks on an element, in this case your button.
The difference is they are two different events registered to different elements in the DOM.
The submit event fires on the
<form>
element itself, and not on any<button>
.The submit event only fires when the user clicks a submit button
By default your submit button has a type of type="submit"
On the other hand the click event is fired when the user clicks on an element, in this case your button.
answered Mar 8 at 15:37
NarmNarm
3,2261135
3,2261135
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
add a comment |
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
Got it, thanks a lot.
– Ali
Mar 8 at 16:18
add a comment |
One of the differences that i know so far, is that if you are inside a ngForm
and if you have a (ngSubmit)
event, the function that is linked to this event will be executed if you press ENTER key.
This is helpfull to go through forms quickly, without touching the mouse.
There are more info on the subject at this address
https://angular.io/guide/reactive-forms
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
add a comment |
One of the differences that i know so far, is that if you are inside a ngForm
and if you have a (ngSubmit)
event, the function that is linked to this event will be executed if you press ENTER key.
This is helpfull to go through forms quickly, without touching the mouse.
There are more info on the subject at this address
https://angular.io/guide/reactive-forms
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
add a comment |
One of the differences that i know so far, is that if you are inside a ngForm
and if you have a (ngSubmit)
event, the function that is linked to this event will be executed if you press ENTER key.
This is helpfull to go through forms quickly, without touching the mouse.
There are more info on the subject at this address
https://angular.io/guide/reactive-forms
One of the differences that i know so far, is that if you are inside a ngForm
and if you have a (ngSubmit)
event, the function that is linked to this event will be executed if you press ENTER key.
This is helpfull to go through forms quickly, without touching the mouse.
There are more info on the subject at this address
https://angular.io/guide/reactive-forms
answered Mar 8 at 15:33
HMarteauHMarteau
436216
436216
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
add a comment |
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, just the same that answered by @Narm
– Ali
Mar 8 at 16:22
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
Yes, i replied before him though... Glad to help
– HMarteau
Mar 11 at 7:24
add a comment |
There is no flagrant difference between the two. The answer made by @HMarteau is inaccurate however, as you can use the 'Enter' button to submit an Angular form whether using the ngSubmit
or the click
event.
The main difference is that Angular's ngSubmit
allows you to use some powerful built in properties such as required
, max-length
, etc., used for validation, which you might not be able to use in the case of click
.
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
add a comment |
There is no flagrant difference between the two. The answer made by @HMarteau is inaccurate however, as you can use the 'Enter' button to submit an Angular form whether using the ngSubmit
or the click
event.
The main difference is that Angular's ngSubmit
allows you to use some powerful built in properties such as required
, max-length
, etc., used for validation, which you might not be able to use in the case of click
.
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
add a comment |
There is no flagrant difference between the two. The answer made by @HMarteau is inaccurate however, as you can use the 'Enter' button to submit an Angular form whether using the ngSubmit
or the click
event.
The main difference is that Angular's ngSubmit
allows you to use some powerful built in properties such as required
, max-length
, etc., used for validation, which you might not be able to use in the case of click
.
There is no flagrant difference between the two. The answer made by @HMarteau is inaccurate however, as you can use the 'Enter' button to submit an Angular form whether using the ngSubmit
or the click
event.
The main difference is that Angular's ngSubmit
allows you to use some powerful built in properties such as required
, max-length
, etc., used for validation, which you might not be able to use in the case of click
.
answered Mar 8 at 15:44
ChrisChris
343115
343115
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
add a comment |
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
Um, you are right, but I can using the FormGroup to do the validation what if using click event. Anyway, thank you as well.
– Ali
Mar 8 at 16:21
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066310%2fangular-form-what-is-the-different-between-submit-event-and-click-event%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown