Module License: MIT
Added by: Sam Deering
Spectacular Angular Dependency Injection isolated as a library. Working in Browser and Node environments
Status: STABLE API - UNSTABLE Code sources location - All Test passing
Current Version 0.0.4
Status: UNSTABLE API - UNSTABLE Code sources location - No test
Install the canary version module with:
npm install ng-di@canary
npm install firstname.lastname@example.org
Or the pre-development one
npm install ng-di
Once installed, start using it
var di = require('ng-di'); di.module(...); di.injector(...);
You can also download a ZIP version with both flavours and the mocks helper.
In your web page:
<script src="dist/ng-di.min.js"></script> <script> di.module(...); di.injector(...); </script>
It's available as
di instead of
The public API, considered stable, is(*):
(*)As this library is framework agnostic, the AngularJS concepts and module API methods
module.controller are NOT available inside the Module API
Other non documented utility methods here are for private usage, and can be removed
Please, refer to Angular Documentation on this topics, as ng-di exposes them as-is.
The tests provided have been written in jasmine, and are executed in browser with Karma Runner and in Node with jasmine-node
For your convenience on writing testable code using ng-di, as well as in angular, two utility functions are exposed
var mock = require('ng-di/mock'), //mock.module and mock.inject are available
Include the mock helper in your test flow.
After cloning, the repository...
Install all dependencies
ng-di uses grunt 0.4.x for building the browser version and for testing. You will need to have installed grunt-cli as global
Pass all test in browser and node.
Relies on Karma and assumes a PhantomJS(*) browser installed on your machine
Build the browser version
Creates all browser compatible code on /dist directory
Test and build
(*) After installing PhantomJS, add the executable to your path
#Add phantomJS to MacOSX PATH by editing ~/.bash_profile export PHANTOMJS_BIN=/Applications/phantomjs-1.9.0-macosx/bin/phantomjs
The goal behind this project is closing the gap between the browser and node environments for developing testable libraries and applications that could be used in both environments.
Just provide different implementations for those environment dependant code (Browser XMLHttpRequest vs. Node http) and reuse all the application code
ng-di isolates you from the dependency injection in environments, but you will have to deal with the CommonsJS/AMD/no-module problem by yourself. Ideas are always welcome!
ng-di uses semantic versioning
var di = require('ng-di');
This work is more-than-heavily based on AngularJS Dependency injection. All credits must go to the Angular Developers Licensed under the MIT license.
Module stats last updated: 2017-02-10 16:00:06