Is that possible in some way to intercept and handle http responses being outside Angular? I can't use $httpProvider because target script is loaded after Angular has been initialized. So I need something that would work like ajaxSuccess in jQuery.
1 Answer
It is rarely recommended to do that because it is un-Angular and usually indicates poor app design. But nothing stops the one from using Angular features outside of the app.
angular.module('httpModule', ['ng'], function ($httpProvider) {
$httpProvider.interceptors.push(...);
});
var http = angular.injector(['httpModule']).get('$http');
XMLHttpRequestobject itself before other library loads. Keep in mind that$httpwill also use it too