2016-05-23 7 views
0

私はちょうど角JSフレームワークを学ぶために始めた、私はこの非常に奇妙な疑問を得る:)Angular JS - モジュールの依存関係はどうですか?

インスタンス用のモジュールに名前を付けた後 - moduleName そしてこのmoduleNameが依存 - anotherModule

次に、あなたが書く:

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

しかしanotherModuleanotherAwesomeModuleに依存している場合、私が書く必要があります:

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

それとも、それは自分自身を世話するつもりですか?私は疑問に思って...

+0

私の質問がExtreeeeeeeeemely Stupidなら、申し訳ありません。私はちょうどAngular JSを学び始めた –

答えて

1

この

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

が動作します。

そして、それ自体がanotherAwesomeModuleに依存moduleName場合

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

を行うには良いことです。 anotherModuleがそれに依存しなくても、コードは意図したとおりに動作します。

+0

ニースの答え、ありがとう! –

関連する問題