Showing Spinner GIF during $http request in Angula

2019-01-01 04:40发布

I am using the $http service of angular to make an ajax request.

How to show a loader gif during the ajax request?

I don't see any ajaxstartevent or similar event in documentation.

标签: angularjs
25条回答
余生请多指教
2楼-- · 2019-01-01 05:21

Just discovered the angular-busy directive that shows a little loader depending on some async call.

For example, if you have to make a GET, reference the promise in your $scope,

$scope.req = $http.get('http://google.fr');

and call it like so :

<div cg-busy="req"></div>

Here is the GitHub.

You can also install it using bower (don't forget to update your project dependencies):

bower install angular-busy --save
查看更多
登录 后发表回答