2016-05-23 20 views
0

我剛開始學角度JS框架和我得到這個怪異無比疑問:)Angular JS - 如何提及模塊依賴關係?

你的名字,例如一個模塊後 - moduleNamemoduleName取決於 - anotherModule

然後,你寫的:

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

但如果anotherModule取決於anotherAwesomeModule,我應該寫:

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

還是要照顧自己?我想知道..

+0

對不起,如果我的問題是Extreeeeeeeeeely愚蠢。我剛剛開始學習Angular JS –

回答

1

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

會工作。

而且是做

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

如果moduleName本身取決於anotherAwesomeModule一件好事。即使anotherModule停止依賴它,代碼仍按預期工作。

+0

很好的答案,感謝兄弟! –