AngularJS - how to use ng-click without submitting the form?

前端 未结 1 1219
野趣味
野趣味 2021-02-19 00:18

I have a form that has both ng-click and ng-submit.

ng-submit is meant for the submission, while ng-click calls a separate function like upload, etc.

How do I ma

1条回答
  •  眼角桃花
    2021-02-19 00:57

    ngClick does not submit the form.

    Sometimes, you can have problems because you have two button elements in your form, and they both submit it. To avoid that, specify the type "button" on it. Example :

    function demo ($scope) {
      
      $scope.doSubmit = function () {
        alert('I submit');
      };
      
      $scope.doClick = function () {
        alert('I click');
      };
      
    }
    
    
    

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