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

后端 未结 7 2063
谎友^
谎友^ 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:38

    Use ng-show directive like this ng-show="test" on spinner span:

    Snippet:

    // http://icelab.com.au/articles/levelling-up-with-angularjs-building-a-reusable-click-to-edit-directive/
    
    angular.module("formDemo", [])
    
    .controller("LocationFormCtrl", function($scope) {
      $scope.searchButtonText = "Search";
      $scope.test = "false";
      $scope.search = function() {
        $scope.test = "true";
        $scope.searchButtonText = "Searching";
        // Do your searching here
      }
    });