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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page