Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I am using the $http service of AngularJS to make an Ajax request.

How can a spinner GIF (or another type of busy indicator) be shown while the Ajax request is executing?

I don't see anything like an ajaxstartevent in the AngularJS documentation.

1 Answer

0 votes
by (106k points)
edited by

For showing spinner GIF during a $http request in AngularJS it depends on your specific use case, 

Looking for Angularjs material from basics! Refer to this video on Angularjs provided by Intellipaat:

but a simple way would follow a pattern like as follows:-

.controller('MainCtrl', function ( $scope, myService ) { 

$scope.loading = true; 

myService.get().then( function ( response ) {

$scope.items = response.data; 

}, function ( response ) { 

// TODO: handle the error somehow 

}).finally(function() { 

// called no matter success or failure 

$scope.loading = false; 

}); 

});

Related questions

0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
asked Aug 30, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...