Show progress circular during $http post?

后端 未结 7 1081
名媛妹妹
名媛妹妹 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:16

    All answers are right just add one more thing that $http request is asynchronous you should use like this

    $scope.$apply(function(){
    $scope.isLoading = false;
    });
    

    And as whole like this

    
    

    And in your JS

    $scope.isLoading = true;

    $http.get("/posts")
       .success(function (data) {
             $scope.$apply(function(){
               $scope.isLoading = false;
             });
       });
    

    Note:- Source of the answer is the accepted answer.

提交回复
热议问题