ng-submit not working in angularjs

后端 未结 6 1599
-上瘾入骨i
-上瘾入骨i 2021-02-12 03:37

My view:

相关标签:
6条回答
  • 2021-02-12 04:02

    Silliest mistake ever, make sure you are compiling your js code.

    0 讨论(0)
  • 2021-02-12 04:07

    Even if the button is inside the form and still ng-submit is not working then change your button type to submit.

    <button type="submit" class="btn btn-success" ng-click="login()">Login</button>
    

    P.S: Other answers did not help me until I changed the button type to submit. Hope this helps.

    0 讨论(0)
  • 2021-02-12 04:08

    Thanks to Matt Way's comment - turns out my save button was outside my form. Fixed

    0 讨论(0)
  • 2021-02-12 04:09

    This affects too, there has to be a submit button in the form (button or input type="submit") or ng-submit won't work.

    0 讨论(0)
  • 2021-02-12 04:10

    Maybe you should add 'novalidate' attribute on the form tag to avoid native browser validation as indicated here https://docs.angularjs.org/guide/forms

    0 讨论(0)
  • 2021-02-12 04:14

    for me the problem was 'required' tag on one of the form fields. After removing this tag the form worked again. The old way of solving such problems is to try to comment part of your form and to run the code.

    I prefer using 'novalidate' tag on the form, and button with type="submit" , so that the validation of the form is done by angular.

    0 讨论(0)
提交回复
热议问题