What I'm doing wrong?
According to documentation, I should be able to inject the provider
to module.config
...but I'm getting an error - "Unknown Provider"
http://jsfiddle.net/g26n3/
(function () {
"use strict";
angular.module("ab.core", [])
.provider("ab.core.provider", function () {
console.log("ab.core.provider - constructor");
this.$get = function () {
console.log("ab.core.provider - get");
return { value: "test" };
}
})
.config(["ab.core.provider", function (myProvider) { console.log("ab.core - config " + myProvider.value); }])
.run(function () { console.log("ab.core - run"); });
angular.module("ab", ["ab.core"])
.config(["ab.core.provider", function () { console.log("ab - config"); }])
.run(function () { console.log("ab - run"); });
angular.bootstrap(document, ['ab']);
}());
Actually I have three questions here...
1) How to inject the ab.core.provider
to config of ab.core
module.
2) How to inject the same provider (ab.core.provider
) to config of ab
module.
3) If I will inject the same provider to config of both modules, it will be the same instance of provider or it will be two different instances?
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…