I would like to enhance the header data of http calls. The data exists in $rootScope. So the approach is done via a function passed to transformRequest array of $httpProvider:
angular.module('services.http.intercepting', [])
.config(function ($httpProvider) {
var enhanceHeader = function (data, headersGetter) {
// TODO: how to get $rootScope in function ?????
var headers = headersGetter();
if (headers && $rootScope.xyz {
}
return data;
};
$httpProvider.defaults.transformRequest.push(enhanceHeader);
})