1
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
        };
    }]);
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Juan Diego
  • 1,396
  • 4
  • 19
  • 52

1 Answers1

4

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) {
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
  • If I add flowFactory I dont get any errors at first, but looking at object on console.log() or try to access flowFactory.defaults I get flowFactory.defaults is undefined flowFactory.defaults.headers = {'Authorization':'Bearer ' + token} – Juan Diego Jun 24 '15 at 22:31
  • @JuanDiego could you add `flowFactory` code in question.. you may didn't included `flowFactory.defaults` in `$get` of provider – Pankaj Parkar Jun 24 '15 at 22:34
  • it is the part that is commented, updateHeaders function under flowFactoryHeaders: Should add it to get or how do I access flowFactoryProvider.defaults. I also tried adding a function to the provider to access this headers. – Juan Diego Jun 24 '15 at 22:52
  • @Juan Diego does it helped you? – Pankaj Parkar Dec 28 '15 at 07:29