访问我的自定义服务的配置属性

时间:2016-06-10 10:41:39

标签: javascript angularjs

我尝试将自定义服务访问其config属性以注入http拦截器,如

angular
        .module("common.services")        
        .factory("redirectService",
                ["$resource", "$q", "$location", 
                 redirectService]),
        .config(function ($httpProvider) {
             $httpProvider.interceptors.push('redirectService');
        });
 function redirectService($resource, $q, $location){
   ...
 }

但显然这是不正确的,因为我得到了firebug控制台错误

  

SyntaxError:expect expression,got'。'的.config(功能   ($ httpProvider){

1 个答案:

答案 0 :(得分:3)

中删除最后,
.factory("redirectService",
   ["$resource", "$q", "$location", 
   redirectService]),