【问题标题】:Angular JS -How to mention module dependencies?Angular JS - 如何提及模块依赖?
【发布时间】:2016-09-20 13:26:55
【问题描述】:

我刚开始学习 Angular JS 框架,我有一个非常奇怪的疑问:)

例如在您命名模块之后 - moduleName 而这个moduleName 依赖于-anotherModule

然后,你写:

   var myCoolApp = angular.module('moduleName', ['anotherModule']);

但是如果anotherModule 依赖于anotherAwesomeModule,我应该写:

   var myCoolApp = angular.module('moduleName', ['anotherModule', 'anotherAwesomeModule'])

或者它会照顾好自己?我想知道..

【问题讨论】:

  • 对不起,如果我的问题是 Extreeeeeeeeeemely Stupid 。我刚开始学习 Angular JS

标签: javascript angularjs dependencies


【解决方案1】:

这个

angular.module('anotherModule', ['anotherAwesomeModule']);
angular.module('moduleName', ['anotherModule']);

会起作用的。

这是一件好事

angular.module('anotherModule', ['anotherAwesomeModule']);
angular.module('moduleName', ['anotherModule', 'anotherAwesomeModule']);

如果moduleName 本身依赖于anotherAwesomeModule。即使 anotherModule 不再依赖它,代码仍然可以按预期工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 2023-03-04
    相关资源
    最近更新 更多