I have say two modules:
foo.afoo.b
and an application module:
angular.module("foo", ["foo.a","foo.b"])
I have a service in module foo.b say:
angular.module("foo.b", [])
angular.module("foo.b").factory("helper",helperFn);
which I want to use in one of my controllers in foo.a.
What I have done is simple dependency injection:
angular.module("foo.a", []);
angular.module("foo.a")
.controller("MyController",["helper",MyControllerFn]);
which is working.
My questions are
- How am I getting the "helper" service from module
foo.beven though it is not declared as a dependency for module a? - Will it break at a later stage?
- If it is correct, is this a good practice?
Error: [$injector:unpr] Unknown provider: helperProvider <- helper. Or put some JSFiddle to illustrate your issue.