javascript - Angular JS loading issue -
i trying following angular-spinner working in project:
i trying working http.get calls. far have:
in controllers:
$scope.loading = true; $http.get('js/data/test.json').success(function(results){ $scope.section = results.section; $scope.loading = false; });
in view:
<span us-spinner="{radius:15, width:4, length: 8}" ng-show="loading"></span> <div ng-repeat="post in section" class="inner"></div>
currently loading shows fast, want know correct way use it? how can delay before data loads , spinner shown. ideas?
you try add timeout:
$scope.loading = true; settimeout(function () { $http.get('js/data/test.json').success(function(results){ $scope.section = results.section; $scope.loading = false; } }, 5000);
this wait 5 seconds before trying retrieve data json file.
edit: use $timeout service angular. don't forget include in controller! (thank walfrat)
$timeout(function () { $http.get('js/data/test.json').success(function(results){ $scope.section = results.section; $scope.loading = false; } }, 5000);
Comments
Post a Comment