【发布时间】:2014-04-01 20:06:42
【问题描述】:
我正在努力实现的目标
我想在我的 $http 拦截器中获取当前状态的数据值。我已经创建了拦截器。
问题
我不知道如何在我的拦截器中捕获 $state.current.data。我尝试使用 $injector.get($state) 但无法读取对象的属性。
angular.module('mymodule').factory 'HttpInterceptor', [
'$location', '$injector'
($location, $injector) ->
request: (config) ->
# Do something when sending the request
console.log(config.headers.hasOwnProperty('Authorization'))
if config.headers.hasOwnProperty('Authorization') == false
$location.url("/login")
config
【问题讨论】:
标签: angularjs angularjs-service angular-ui-router