Angular does an excellent job of managing object dependencies. it can even take care of module dependencies.
So we can easily group releated services into one module, and make other modules dependent on it.
    angular.module('my',['my1','my2']);
    the preceding code create a module named "my" which dependent on two other modules "my1" and "my2".

So modules can dependent on other modules and services can dependent on other services.
and this raises several interesting questions, which are as follows:
    1. Can a service defined in one AngularJS module depend on services in another module?

    2. Can services defined in a child module depend on a service in a parent module, or only on services defined in child modules?
    3. Can we have module-private services visible only in a certain module?
    4. Can we have several services with the same name defined in different modules?
    
    angular.module('app',['engines'])
    .factory('car',function(dieselEngine){
        return {
            info:function(){
                console.log(dieselEngine.type);
            }
        };
    });

angular.module('engines',[])
    .factory('dieselEngine',function(){
            return {
                type:'a sport car'
            };
    });
    above code can execute with no problems.
    what's more surprising is that services defined on sibling modules are also visible to each other. check below code snippet out:
    
    angular.module('my',['car','engines']);
    
    angular.module('car',[])
    .factory('carlog',function(dieselEngine){
            return {
                info:function(){
                    console.log(dieselEngine.type);
                }
            };
    });
    
    angular.module('engines',[])
    .factory('dieselEngine',function(){
            return {
                type:'a sport car'
            };
    });

conclusion: a service defined in one of the application's modules is visible to all the other modules. In other words,
        hierarchy of modules doesn't influence services' visibility to other modules. when Angujar bootstraps an application,
        it combines all the services defined across all the modules into one application, that is , global namespace.
        
    Since Angular combines all the services from all modules into one big namespace.

    there can be only one service with a given name.
    
    currently, there is no way to restrict service's visibility to the other modules.

最新文章

  1. 求空间内两条直线的最近距离以及最近点的坐标(C++)
  2. php面向对象之__toString()
  3. Who's in the Middle 分类: POJ 2015-06-12 19:45 11人阅读 评论(0) 收藏
  4. bzoj 2456: mode
  5. Ubuntu下部署SVN+SVNManager
  6. Linux 共享内存编程
  7. poj2163
  8. Spring mybatis源码篇章-sql mapper配置文件绑定mapper class类
  9. APIs
  10. AngularJS进阶(二)AngularJS路由问题解决
  11. 第三周java学习总结
  12. Spring设置定时任务时,关于执行时间的规则设置
  13. POJ 3687 Labeling Balls (top 排序)
  14. 登录页面加密token和盐的作用
  15. [转载]angular通过$http与服务器通信
  16. 在Android Studio中打开Android Device Monitor时报错的解决方法
  17. Comparable 与 Comparator
  18. 解题:NOI 1999 生日蛋糕
  19. 编码规范:Eclipse Checkstyle配置
  20. 每日英语:Hold On: Reasons For Never Giving Up Your Dream

热门文章

  1. 八大排序的python实现
  2. 【学习笔记】快速傅里叶变换(FFT)
  3. 我的Java开发学习之旅------>Java经典排序算法之冒泡排序
  4. 我的Android进阶之旅------>自己写个Activity来调节Android系统背光亮度Brightness
  5. ios之编码规范具体说明
  6. JSP中的内容布局
  7. Spring/Java error: namespace element 'annotation-config' … on JDK 1.5 and higher
  8. BZOJ 3362 Navigation Nightmare
  9. SQL Server 2008R2 代理服务-开启
  10. 系统常用VC++运行时下载地址