How to display timeout error in angular js $http calls?
And if you want to do someting when connection timed out for every request, you can use interceptors (global timeout param doesn't work) :
// loading for each http requestapp.config(function ($httpProvider) { $httpProvider.interceptors.push(function ($rootScope, $q) { return { request: function (config) { config.timeout = 1000; return config; }, responseError: function (rejection) { switch (rejection.status){ case 408 : console.log('connection timed out'); break; } return $q.reject(rejection); } } })})
Have a try on this blog page: http://www.jonhartmann.com/index.cfm/2014/7/23/jsFiddle-Example-Proper-Timeout-Handling-with-AngularJSIt has a complete angular running example which resolve your question.
You can use angular interceptor to achieve this.
$httpProvider.responseInterceptors.push(['$q', '$injector','$rootScope', function ( $q, $injector,$rootScope) { return function (promise) { return promise.then(function (response) { return response; }, function (response) { console.log(response); // response status return $q.reject(response); }); }; }]);}]);