Show progress circular during $http post?

后端 未结 7 1273
名媛妹妹
名媛妹妹 2021-02-08 16:05

What is the best way to use Angular Material\'s Progress circular component with a $http request?

I currently have the code like this below:

Progre

7条回答
  •  没有蜡笔的小新
    2021-02-08 16:29

    I hope this code helps.

      var isLoadingShown = false;
    
      $scope.$watch(function() {
        return $http.pendingRequests.length;
      }, 
      function(newValue, oldValue) {
        console.log(newValue);
        if(newValue !== 0) {
          if(!isLoadingShown) {
            showLoading();         
          }
        }
        else hideLoading();
      });
    
      function showLoading(){
        isLoadingShown = true;   
        $mdDialog.show({
          template: '' +
                      '
    ' + '' + '
    ' + '
    ', parent: angular.element(document.body), clickOutsideToClose:false, escapeToClose: false, fullscreen: false }); } function hideLoading(){ $mdDialog.cancel(); isLoadingShown = false; }

提交回复
热议问题