Preventing / dealing with double button clicks in angular

前端 未结 13 1182
我寻月下人不归
我寻月下人不归 2020-11-27 19:53

In angular we can set up a button to send ajax requests like this in view:

... ng-click=\"button-click\"

and in controller:



        
13条回答
  •  一生所求
    2020-11-27 20:44

    You can handle the form validation 
        $('form.your-form').validate({
            rules: {
                name: 'required',
                email: {
                    required: true,
                    email: true
                }
            },
            submitHandler: function (form) {
                // Prevent double submission
                if (!this.beenSubmitted) {
                    this.beenSubmitted = true;
                    form.submit();
                }
            }
        });
    

提交回复
热议问题