2016-06-26 3 views
1

안녕하세요 대단한 Stackoverflow, 각도 js를 배우고 있으므로 각도 j를 통해 데이터베이스 레코드를 쿼리하고 모든 것이 잘 작동합니다. 이제 데이터베이스 콘텐츠가 로딩 될 때 로딩 이미지를 표시하고 콘텐츠가로드되면 이미지가 사라집니다. 제발 어떻게 달성해야합니까. 아래 각도 js에서 로딩 이미지를 표시하는 방법

감사

당신은 $http.get("data.php").success(function(response){ 라인 전에 $scope.loading = true;처럼 떨어지게을 추가 할 수있는 작업 코드

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 
    } 
}); 
+0

과 같은 일반적인 $ http 요청에 대한 예제를 만들었습니다. [here] (https://jsfiddle.net/2yguh217/29/)와 같은 모양을 사용하십시오. –

답변

1

입니다. 성공 함수 내 $scope.loading = false;. 마크 업에서 <table ng-hide="loading"><img ng-show="loading" src="loader.gif">

관련 문제