Interceptors act as a hook up for the HTTP calls.
The $httpProvider provider contains an array of interceptors. An interceptor is simply a regular service factory that is registered to that array.
The following code shows how to create intercepters
module.factory('myInterceptor', ['$log', function($log) {
$log.debug('$log is here to show you that this is a regular factory with injection');
var myInterceptor = {
....
....
....
};
return myInterceptor;
}]);
Injectors are primarily used in adding custom logic for authentication, authorization, session/state management, logging, modifying Response, URL rewriting, Error handling, Caching, adding custom header, timestamp in the request /response, encrypt and decrypt the request and response information or manipulate the request and response data over the request cycles.