0

I am assuming because it is a standard practice in the Angular world that, any sort of module system has to be wrapped as an Angular module and angular should be the only global variable used which will avoid any conflict.

gustavohenke
  • 845
  • 9
  • 16
Amogh Talpallikar
  • 1,997
  • 2
  • 26
  • 39
  • "enclosing the contents of a file in a closure" You mean an IIFE? I don't really understand how you mean that they'd go about using closures for their modules... What would the closure contain? A reference to the angular object? – Jan Sep 09 '15 at 17:07

1 Answers1

1

It is not only standard practice in Angular, but in all software: Try to minimize global objects / variables / functions as much as possible. For reasons, see Why is Global State so Evil?

But this could be avoided in other ways as Angular, one could e.g. append your object to the ng object, but this is something like a "global state in Angular".

The main feature is the possibility of dependency injection: You inject modules into angular with a predefined interface, one implementation of the I in SOLID.

That enables you to mock objects for unit testing, and enables test driven-development.

Residuum
  • 3,282
  • 28
  • 31