我正在玩角度,我遇到了一个小问题.
我正在尝试为http响应设置自定义标头,然后在angular的一侧读取它的值.标题已设置,我确信这是因为chrome的调试工具确认:
这意味着服务器端很好.到现在为止还挺好.
当我尝试通过http响应拦截器以角度访问标头并在控制台中显示它们时,会出现问题.这是coffeescript中的代码:
angular.module('app').factory 'httpInterceptor', function($q) ->
(promise) ->
success = (response) ->
console.log response.headers()
response
error = (response) ->
$q.reject(response)
promise.then success, error
angular.module('app').config ($httpProvider) ->
$httpProvider.responseInterceptors.push('httpInterceptor')
Run Code Online (Sandbox Code Playgroud)
我得到输出:
我真的不明白为什么角度剥离所有这些标题.有谁可以向我解释一下?有没有办法访问我的自定义标头的值?
先感谢您.