External dependency loader for quick ng prototyping
Declare your dependencies in one place, and speed up your prototyping!
angular.module('main')// Declare dependencies and their source _in your javascript_.dependency('ui.router','//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.min.js').dependency('main.login','main/login.js').controller(fn);// Declare sub-modules without dependency annotationangular.module('login').dependency('ui.router');Go from this verbosity...
<scriptsrc="lib/angular/angular.js"></script><scriptsrc="lib/dependency/dependency.js"></script><scriptsrc="lib/angular-scroll/angular-scroll.min.js"></script><scriptsrc="app.js"></script><scriptsrc="common/services/contacts.js"></script><scriptsrc="common/directives/table.js"></script><scriptsrc="lounge/lounge.js"></script><scriptsrc="lounge/directive.js"></script><scriptsrc="dining/dining.js"></script><scriptsrc="dining/controller.js"></script><scriptsrc="dining/directive.js"></script><scriptsrc="smoking/smoking.js"></script><scriptsrc="smoking/service.js"></script><!-- ... -->...to this.
<scriptsrc="lib/angular/angular.js"></script><scriptsrc="lib/dependency/dependency.js"></script><scriptsrc="app.js"></script>Instead of listing your dependencies twice, do it all in javascript.
- Grab it from your favorite registry:
curl https://raw.githubusercontent.com/zzmp/dependency/master/dependency.js > lib/dependency/dependency.jsgit clone git@github.com:zzmp/dependency.gitbower install dependencynpm install ng-dependency
- Include it in your index.html, just after angular:
<scriptsrc="lib/angular/angular.js"></script><scriptsrc="lib/dependency/dependency.js"></script>angular.module('main').dependency('depName','/depPath.js');angular.module('main').dependency({'depName': '/depPath.js','depTwo' : '/depTwo.js','cdnDep' : '//url'});angular.module('main').dependency(['depName','depTwo','cdnDep']);/* sources.js */angular.dependency({'depName': '/depPath.js','depTwo' : '/depTwo.js','cdnDep' : '//url'});angular.module('main')
.dependency('depName')
// Only loaded once, from first given path '/depPath'
.dependency('depName', '/depPath')
// Already loaded, new path is ignored
.dependency('depName', '/fakePath');
I work best with prototyping. I do not (yet) concatenate code, so don't use me for something that needs to minimize AJAX calls. I am great for CDN-distributed dependencies.