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










0















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.










share|improve this question


























    0















    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.










    share|improve this question
























      0












      0








      0








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 15:28









      AliAli

      31




      31






















          3 Answers
          3






          active

          oldest

          votes


















          3














          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.






          share|improve this answer























          • Got it, thanks a lot.

            – Ali
            Mar 8 at 16:18


















          1














          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






          share|improve this answer























          • 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



















          0














          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.






          share|improve this answer























          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          3














          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.






          share|improve this answer























          • Got it, thanks a lot.

            – Ali
            Mar 8 at 16:18















          3














          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.






          share|improve this answer























          • Got it, thanks a lot.

            – Ali
            Mar 8 at 16:18













          3












          3








          3







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 15:37









          NarmNarm

          3,2261135




          3,2261135












          • 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





          Got it, thanks a lot.

          – Ali
          Mar 8 at 16:18













          1














          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






          share|improve this answer























          • 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
















          1














          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






          share|improve this answer























          • 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














          1












          1








          1







          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






          share|improve this answer













          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


















          • 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












          0














          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.






          share|improve this answer























          • 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















          0














          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.






          share|improve this answer























          • 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













          0












          0








          0







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived