0

I am trying to call a a service/provider/factory/whatever method, in the config function of a module, on the templateUrl of routerProvider, like this :

angular.module('myapp.security.user').config(config);
config.$inject = ['$routeProvider'];
function config($routerProvider) {
    $routerProvider
        .when('/login', {
                templateUrl: template.get('/lol'),
                //...
            },
        })
    ;
};

At first, following this documentation : https://github.com/johnpapa/angularjs-styleguide#minification-and-annotation (last piece of code before chapter "Minification and annotation"), I though that all I need to do was to use a service. But AngularJS was yelling at me that the service was not defined. So I used a provider, but this is not working either.

The fact is I use the following architecture : module : my_app (where the service/provider/factory is defined) module : my_app.security module : my_app.security.user (where I want to use the service/provider/factory)

I don't know how to call this "main" service from within my config submodule.

Here is the condensed JS for the application (loaded in the defined order): http://pastebin.com/NTj09HdC

I'm running out of ideas.

Alex Ception
  • 214
  • 3
  • 12

1 Answers1

0

It appears that I had a cyclic dependency.

My provider was defined in the module "myapp", the module "myapp" was depending on "myapp.security". And the module "myapp.security" was requiring the provider from "myapp". I solved the conflict by adding a new module "myapp.shared" containing the provider.

Alex Ception
  • 214
  • 3
  • 12