javascript - Angular modules and dependency injection -
let's say: use module called constants.
angular.module("constants", []) .constant("a", 10); i want use constant a in module:
angular.module("modulethatuseconstants", ["constants"]) .service("b", ["a", services.b]); // here use that works ! if have constant (or controller etc) called a ?
angular.module("modulethatuseconstants", ["constants"]) .service("a", [services.a]); .service("b", ["a", services.b]); // ??? question: how specify a comes module constants ? tried:
.service("b", ["constants.a", services.b]); but doesn't work $injector:unpr unknown provider "constants.a"
you cannot achieve this. later 1 same name resolved. 1 of shortcomings of di in angular 1.x. expect see solution in angular 2 di.
Comments
Post a Comment