I'm getting started with AngularJS, and I'm trying to wrap my head around dependency injection. Specifically, I'm trying to understand the differences between DI and declaring dependencies with RequireJS.
Does DI in Angular only work for "objects" (Factories, Services, Models) which are defined on some angular.module? For example, could I depend on some external library like jQuery using DI?
In general, can the difference between dependency management in RequireJS and DI in Angular be stated like this:
RequireJS deals with loading dependencies only when they are first needed (lazy loading) and makes sure all dependencies exist before executing, whereas Angular DI allows easily changing a dependency, in runtime, as long as it's interface stays the same?
And finally, does DI always pass in instance of the dependency? A new instance every time, or a singleton? Can it pass in a "Class" definition which I can instantiate myself? For example, what if I need to pass options to the constructor?