您好,伟大的 Stackoverflow,我正在学习 Angular JS,所以我正在通过 Angular JS 查询数据库记录,一切正常。现在我想在加载数据库内容时显示加载图像,并且一旦加载内容,图像就会消失。请问我该如何实现这一点。谢谢
下面是工作代码
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
}
});
最佳答案
您可以添加类似 $scope.loading = true;
的内容之前$http.get("data.php").success(function(response){
线。
和$scope.loading = false;
内部成功函数。
在标记中,类似 <table ng-hide="loading">
和<img ng-show="loading" src="loader.gif">
关于javascript - 如何在 Angular js中显示加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38037570/