1

Hello great Stackoverflow, am learning angular js and so am querying database records via angular js and everything works fine. now i want to display a loading image as the database content is loading and the image will fade off as soon as the content is loaded. please how do i achieve that. Thanks

below is the working code

var app = angular.module('angularTable', ['angularUtils.directives.dirPagination']);

app.controller('listdata',function($scope, $http){
    $scope.users = []; //declare an empty array

    $http.get("data.php").success(function(response){ 

        $scope.users = response;  //ajax request to fetch data into $scope.data
    });

    $scope.sort = function(keyname){
        $scope.sortKey = keyname;   //set the sortKey to the param passed
        $scope.reverse = !$scope.reverse; //if true make it false and vice versa
    }
});
1
  • I made an example for general $http requests using directive take a look if you like here. Commented Jun 26, 2016 at 10:53

1 Answer 1

1

You can add smth like $scope.loading = true; before $http.get("data.php").success(function(response){ line. And $scope.loading = false; inside success function. In markup, smth like <table ng-hide="loading"> and <img ng-show="loading" src="loader.gif">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.