我刚刚开始学习Angular JS Framework,我得到了非常奇怪的疑问:)
例如命名模块后 - moduleName
此moduleName
取决于 - anotherModule
然后,你写道:
var myCoolApp = angular.module('moduleName', ['anotherModule']);
但如果anotherModule
取决于anotherAwesomeModule
,我应该写一下:
var myCoolApp = angular.module('moduleName', ['anotherModule', 'anotherAwesomeModule'])
还是会照顾好自己?我想知道..
答案 0 :(得分:1)
此
angular.module('anotherModule', ['anotherAwesomeModule']);
angular.module('moduleName', ['anotherModule']);
会奏效。
这是一件好事
angular.module('anotherModule', ['anotherAwesomeModule']);
angular.module('moduleName', ['anotherModule', 'anotherAwesomeModule']);
如果moduleName
本身取决于anotherAwesomeModule
。即使anotherModule
停止依赖它,代码仍然按预期工作。