问题
First, some context for my question, which is also explained in the MEAN.JS docs: my angular app Foo
is bootstrapped from my init.js
file, which has this line:
angular.element(document).ready(function () {
angular.bootstrap(document, ['FooCore']);
});
My FooCore
app has several vendor dependencies that I list in the normal manner in its setter which happens just before this line.
Next, the components of my app (search, profile, dashboard, etc) are in their own modules. Every time I declare a sub-component of FooCore
I add it to its dependencies with:
angular.module('FooCore').requires.push('ModuleBar');
So, logically, all of my app's components are able to talk to each other (e.g. share directives), which makes sense to me. My question is this: say ModuleBar
has a vendor dependency X that only it needs - so I declare that dependency in ModuleBar
's setter - why is X available to all the sibling components of my FooCore
app? Here's a visual representation:
FooCore
|----ModuleBar => angular.module('ModuleBar', ['vendor-X']);
| |---- vendor-X
|
|----ModuleBaz => angular.module('ModuleBaz', []);
Shouldn't vendor-X
only be available to ModuleBar
? Why am I finding it is available to ModuleBaz
as well?
来源:https://stackoverflow.com/questions/30364119/angularjs-module-sub-dependencies-available-to-sibling-modules