Show progress circular during $http post?

后端 未结 7 1594
旧巷少年郎
旧巷少年郎 2021-02-08 15:56

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:34

    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.

提交回复
热议问题