0

I have app that use webpack and babel, the code look like this:

app.js

import angular from 'angular';
import 'jquery';
import components from './components/index';
import services from './services/index';
import './app.css';

angular.module('app', [components.name, services.name])
    .config((rpc) => {
        rpc.setup('rpc.scm');
    });

services/index.js

import angular from 'angular';
import rpc from './rpc';

var module = angular.module('services', []);

module.provider('rpc', rpc);

export default module;

services/rpc.js

import $ from 'jquery';

export default function() {
   var service = {};
   this.setup = function(uri) {
       // create service based on system.describe
   };
   this.$get = function() {
       return service;
   }
};

and I got error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: rpc

I don't get any errors from webpack.

jcubic
  • 61,973
  • 54
  • 229
  • 402

1 Answers1

1

the provider should be injected as follows:

angular.module('app', [components.name, services.name])
 .config((rpcProvider) => {
});

since .config only accepts nameofprovider + Provider (camel case).

more info here: AngularJS - Inject provider to module.config

Community
  • 1
  • 1
Paolo
  • 704
  • 9
  • 24