我在 angularjs 中使用 $resource 服务从服务器异步加载 json 内容。加载内容时,我会在页面上显示一个 gif 加载器。我需要知道异步请求何时完成,以便删除加载程序。我怎样才能捕捉到准备好的事件,以便我可以删除装载机?
function PlaylistController($scope, $route, $http, Song,Artists,Albums,Drive,Children){
function render(){
$scope.songs = Song.list()
//Obviously this removes the loading class immediately
//I want to remove it when Song.list() is complete
$('body').removeClass('loading');
}
$scope.$on("$routeChangeSuccess", function($currentRoute, $previousRoute){
//When the route changes,update the $scope variables
render();
});