prevent multiple form submissions using angular.js - disable form button

后端 未结 9 756
耶瑟儿~
耶瑟儿~ 2020-12-13 21:22

I want to prevent multiple form submissions using angular.js. The question is related to this question.

When the user clicks on a form submit button the value / labe

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 21:50

    Just add a new property in your controller

    $scope.processing = false;
    

    In your method

    $scope.processData = function(){
        $scope.processing = true;
        $http.post('').then(function(){
            $scope.processing = false;
        });
    });
    

    In your html bind ng-disabled attribute to the $scope.processing property to disable the button and show text while the method is processing.

提交回复
热议问题