Tilak Madichetti
Tilak Madichetti

Reputation: 4346

Angular JS -How to mention module dependencies?

I just started to learn Angular JS Framework and I get this extremely weird doubt:)

After you name a module for instance - moduleName And this moduleName depends on - anotherModule

Then, you write:

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

But if anotherModule depends on anotherAwesomeModule, should I write:

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

Or is it going to take care of itself ?? I am Wondering ..

Upvotes: 0

Views: 86

Answers (1)

Estus Flask
Estus Flask

Reputation: 222369

This

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

will work.

And it is a good thing to do

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

if moduleName itself depends on anotherAwesomeModule. Even if anotherModule stops to depend on it, the code still works as intended.

Upvotes: 1

Related Questions