ng-submit not working in angularjs

女生的网名这么多〃 提交于 2019-12-03 09:35:52

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

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.

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

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

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!