AngularJS Module sub dependencies available to sibling modules?

拟墨画扇 提交于 2019-12-11 02:39:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!