Unknown Provider error Angular

662 views Asked by At
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

This is my code, maybe I am just tired but what I am trying is to inject the provider on the factory, but nothing I tried worked. I am trying to change the values in 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

There are 1 answers

4
Pankaj Parkar On BEST ANSWER

Providers are available with Provider post-fix only config phase only

You don't have access to provider inside factory, they named as without Provider postfix here in service. It would be simply flowFactory here

Code

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