angularjs disable button on $http/$q calls

前端 未结 9 779
失恋的感觉
失恋的感觉 2021-02-03 10:12

following the DRY principal, i want to write a button directive which keeps button disabled for the duration of $http class.

I want to do this so as to forbid user from

9条回答
  •  粉色の甜心
    2021-02-03 11:04

    Why not just make it easier.

    
    
    
    $scope.save = function(){
      $scope.isProcessing = true;
      $http.post('Api/Controller/Save', data).success(
        $scope.isProcessing = false;
      );
    }
    

    Sure it's the case if you need this logic in very few places across your app.

    If you have such logic repeating many times (and if you are not lazy :) ), so in order to follow SOLID principles it definetely better to wrap this functionality into directive (check out other answers for this question to see examples of such directive).

提交回复
热议问题