Tilak Madichetti Tilak Madichetti - 1 year ago 76
Javascript Question

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 -


And this
depends on -

Then, you write:

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

But if
depends on
, should I write:

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

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

Answer Source


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download