Saturday 18 October 2014

Angular Request Count & Loading Widget (ng 1.3.0)

I my older post (AngularJS Loading Widget) I have described how to count requests and keep track of their count to be able to notify user when something gets loaded. In the new version 1.3.0 of Angular the response transformer is not called when the request fails or returns empty response. I have updated to Interceptors. I’ve avoided using them for this purpose because I was not getting constant results with them. But now I don’t know of other options. Here’s the updated code of the .config phase. Please let me know if you come across any issues. Working JSFiddle demo. If you want to know how this works, read the older post.

angular.module('myApp', [
.config(function (
requestNotificationProvider) {
$httpProvider.interceptors.push(function ($q) {
return {
request: function (config) {
return config;
response: function (response) {
return response;

responseError: function (rejection)
return $q.reject(rejection);

No comments:

Post a Comment