未知的提供程序错误Angular

时间:2015-06-24 21:40:00

标签: javascript angularjs dependency-injection angularjs-factory angularjs-provider

Error: [$injector:unpr] Unknown provider: flowFactoryProviderProvider <- flowFactoryProvider <- flowFactoryHeaders
http://errors.angularjs.org/1.3.15/$injector/unpr?p0=flowFactoryProviderProvider%20%3C-%20flowFactoryProvider%20%3C-%20flowFactoryHeaders
minErr/<@http://unika.localdomain/bower_components/angular/angular.js:63:12

这是我的代码,也许我只是累了,但我正在尝试的是在工厂注入提供商,但我没有尝试过。我正在尝试更改flowFactoryProvider中的值,flowFactoryProvider.defaults

var upload = angular.module('UploadModule', [ 'ngResource','flow' ])
  upload.config(
        [ 'flowFactoryProvider',function(flowFactoryProvider) {
            //AuthService.getKeycloak();

            flowFactoryProvider.defaults = {
                target : 'https://localhost:8443/unika/upload',
                permanentErrors : [ 500, 501 ],
                maxChunkRetries : 1,
                chunkRetryInterval : 5000,
                simultaneousUploads : 4,
                progressCallbacksInterval : 1,
                withCredentials : true,
                method : 'octet',
            };
            flowFactoryProvider.on('catchAll', function(event) {
                console.log('catchAll', arguments);
            });
            // Can be used with different implementations of Flow.js
            // flowFactoryProvider.factory = fustyFlowFactory;
        } ]);

    upload.factory('flowFactoryHeaders',['flowFactoryProvider',function(flowFactoryProvider) {
        var token;

        var setToken = function(token){
            this.token = token;
        }

        var getToken = function(){
            return this.token;
        }

        /*var updateHeaders = function(){
            flowFactoryProvider.defaults.headers = {'Authorization':'Bearer ' + token}
        }*/
        return {
            setToken: setToken,
            getToken: getToken
        };
    }]);

1 个答案:

答案 0 :(得分:4)

  

提供商仅提供Provider仅修复后配置阶段

您无权访问provider内的factory,他们在服务中将其命名为没有提供商后缀。这只是flowFactory

<强>代码

upload.factory('flowFactoryHeaders',['flowFactory',function(flowFactory) {