角JS - 听或绑定$ http请求
有没有听/每次绑定一个事件有一个$ http请求并收到响应后也?一个办法
Is there a way to listen/bind an event every time there's an $http request and also after it receives a response?
其实我提供我自己的事件和监听器手工完成它,但我只是好奇,如果已经有一个在JS角本?
Actually I've done it manually by providing my own events and listeners, but I'm just curious if there's already a listener in Angular JS for this?
为什么我想这样做的原因是,每次我的应用程序发送的时间/执行$ http请求我想表明我的加载屏幕,表明应用程序是获取它收到响应之后,数据然后将其隐藏。
The reason why I wanted to do this is that, every time my application sends/execute an $http request I wanted to show my loading screen to indicate that the app is retrieving data then hide it after it receives a response.
谢谢!
您可以使用角加载酒吧。它自动加载栏的进步,通过采用了棱角分明的拦截器。在同一时期内的多个请求将捆绑在一起,使得每个响应由加适量的进度条。
You can use Angular Loading Bar. It automates the loading bar's progress, by using angular interceptors. Multiple requests within the same time period get bundled together such that each response increments the progress bar by the appropriate amount.
app.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.includeSpinner = false; // second boot loader, you can show or hide
cfpLoadingBarProvider.includeBar = true; // main loader
cfpLoadingBarProvider.latencyThreshold = 200; // delay
}])
希望这有助于...
hope this helps...