How to add a spinner while loading the content in AngularJS?

后端 未结 7 2060
谎友^
谎友^ 2021-01-02 02:09

I am using button spinner while loading the content, when the user clicks on the \"Search\" button content will load, at this time buttonLabel will be changed t

7条回答
  •  再見小時候
    2021-01-02 02:31

    Just add an ng-show to your spinner:

    
    

    and controller:

    .controller("LocationFormCtrl", function ($scope) {
        $scope.searchButtonText = "Search";
        $scope.loading = false;
        $scope.test="false";
        $scope.search = function() {
          $scope.test="true";
          $scope.loading="true"
          $scope.searchButtonText = "Searching";
          // Do your searching here
       }
    });
    

    Then, when you get your response, set $scope.loading to false again

    Demo

提交回复
热议问题