with $http, we can do this:
var config = { headers: { \'something\': \'anything\' } };
$http.get(\'url/to/json\', config)
.success(function()
The headers
object inside a resource action supports both static
values for its fields, but also dynamic
values returned from a function.
$resource('url/to/json', {}, {
get: {
method: 'GET',
headers: {
'header_static': 'static_value',
'header_dynamic': dynamicHeaderVal
}
}
});
function dynamicHeaderVal(requestConfig){
// this function will be called every time the "get" action gets called
// the result will be used as value for the header item
// if it doesn't return a value, the key will not be present in the header
}