加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 在角度模块创建后添加依赖关系

发布时间:2020-12-17 07:47:08 所属栏目:安全 来源:网络整理
导读:你们知道是否可以在创建模块后添加模块依赖关系?这样的事情 // init module in file Aangular.module("myApp",[]);// retrieve module in file B and add new dependencies:mod = angular.module("myApp");// now I want to add an 'ngResource' dependency
你们知道是否可以在创建模块后添加模块依赖关系?这样的事情
// init module in file A
angular.module("myApp",[]);

// retrieve module in file B and add new dependencies:
mod = angular.module("myApp");
// now I want to add an 'ngResource' dependency to mod
// ???

编辑:我明白这可能是一个奇怪的问题.我正在研究一个基于组件的应用程序组织,并希望看到子组件是否可以在父组件模块中添加依赖关系而不定义自己的模块.这样的事情

app/
 components/
   |__componentA/ 
        |__app.js // initializes component A module
        |__subcomponentA/ 
              |__app.js // want to add subcomponentA dependencies to componentA module from here

我的替代方法是直接在componentA模块上声明所有的subcomponentA依赖关系,但从组织的角度来看,我宁愿把这些依赖项保留在subcomponentA目录中,所以如果我以后决定从应用程序中删除子组件A,需要记住从componentA模块中删除它的依赖关系.我希望将关于子组件A的所有内容分组到子组件A目录中.我的构建脚本将确保componentA代码在子组件A之前被处理.

谢谢大家谁刺伤了这个.

我使用以下方法,为我工作正常.
var app = angular.module("myApp",[]);

angular.module("myApp").requires.push('ngResource');

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读