How do you disable the submit button after a single click to prevent multiple submissions in Angularjs?

前端 未结 10 1983
礼貌的吻别
礼貌的吻别 2020-12-23 14:35

I\'ve looked all over the web including several stack overflow examples for a solution to the question. To be specific, I tried this:

10条回答
  •  有刺的猬
    2020-12-23 14:58

    I didn't like any of the provided answers as they all clutter the global scope with the isDisabled variable, why not do it this way instead?

    
    

    .

    $scope.disableButton = function($event) {
        $event.currentTarget.disabled = true;
    };
    

    if if you need to submit a form before the disable.

    this code is not tested

    .

    $scope.disableFormSubmitButton = function($event) {
        $($event).find('[type=submit]').prop('disabled',true);
    };
    

提交回复
热议问题