{"id":13624452,"url":"https://github.com/jmendiara/ng-di","last_synced_at":"2025-04-28T22:31:20.910Z","repository":{"id":5275196,"uuid":"6454104","full_name":"jmendiara/ng-di","owner":"jmendiara","description":"Spectacular Angular Dependency Injection for Javascript isolated as a library. Working in Node and Browser","archived":false,"fork":false,"pushed_at":"2015-11-16T08:15:57.000Z","size":4225,"stargazers_count":35,"open_issues_count":1,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T01:37:48.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"melvincabatuan/DibDibAdvocacy","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmendiara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-30T08:30:16.000Z","updated_at":"2025-01-02T01:11:09.000Z","dependencies_parsed_at":"2022-09-09T13:40:50.682Z","dependency_job_id":null,"html_url":"https://github.com/jmendiara/ng-di","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmendiara%2Fng-di","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmendiara%2Fng-di/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmendiara%2Fng-di/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmendiara%2Fng-di/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmendiara","download_url":"https://codeload.github.com/jmendiara/ng-di/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251397582,"owners_count":21583035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:01:42.752Z","updated_at":"2025-04-28T22:31:16.818Z","avatar_url":"https://github.com/jmendiara.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# ng-di\r\n\r\nSpectacular Angular Dependency Injection isolated as a library. Working in Browser and Node environments\r\n\r\n[![Build Status](https://travis-ci.org/jmendiara/ng-di.png)](https://travis-ci.org/jmendiara/ng-di)\r\n\r\n## Getting Started\r\n### On the server\r\n```bash\r\nnpm install ng-di\r\n```\r\n\r\nOnce installed, start using it\r\n```javascript\r\nvar di = require('ng-di');\r\ndi.module(...);\r\ndi.injector(...);\r\n```\r\n\r\n### In the browser\r\nDownload the [production version](dist/ng-di.min.js) or the [development version](dist/ng-di.js).\r\n\r\nYou can also download a [ZIP version](dist/ng-di.zip) with both flavours and the mocks helper.\r\n\r\nIn your web page:\r\n\r\n```html\r\n\u003cscript src=\"dist/ng-di.min.js\"\u003e\u003c/script\u003e\r\n\u003cscript\u003e\r\ndi.module(...);\r\ndi.injector(...);\r\n\u003c/script\u003e\r\n```\r\n\r\n\r\n## Documentation\r\nThis library simply isolates [AngularJS](http://www.angularjs.org)\r\n[dependency injection](http://docs.angularjs.org/guide/di), exposing its\r\n[module API](http://docs.angularjs.org/guide/module) as part of it.\r\n\r\nAll the DOM management has been removed, and makes this library the ideal artifact for using\r\n Javascript Dependency Injection in javascript only apps, libraries...\r\n \r\nIt's available as `di` instead of `angular`\r\n\r\nThe public API, considered stable, is(*):\r\n * [module](https://docs.angularjs.org/api/ng/type/angular.Module). Exposed as `di.module`\r\n * [injector](https://docs.angularjs.org/api/auto/service/$injector). Exposed as `di.injector`\r\n * [annotate](https://docs.angularjs.org/api/auto/service/$injector). Exposed as `di.annotate`\r\n\r\n(*)As this library is framework agnostic, the AngularJS concepts and module API methods `module.directive` \r\nand `module.controller` are NOT available inside the Module API\r\n\r\nOther non documented utility methods here are for private usage, and can be removed \r\n\r\nPlease, refer to Angular Documentation on this topics, as ng-di exposes them as-is.\r\n\r\n## Examples\r\nYou can go to the [examples](examples) folder to see how to use in [node](examples/node) and [browser](examples/browser)\r\n\r\n## Testing\r\nThe tests provided have been written in jasmine, and are executed in browser with Karma Runner and in Node with jasmine-node\r\n\r\nFor your convenience on writing testable code using ng-di, as well as in angular, two utility functions are exposed\r\n```javascript\r\nmock.module(...);\r\nmock.inject(...);\r\n```\r\n\r\nYou can read through [code documentation](mock/index.js#L65) or learn by watching [examples](#examples)\r\n\r\n### node\r\n```javascript\r\nvar mock = require('ng-di/mock'),\r\n//mock.module and mock.inject are available\r\n```\r\n\r\n### Browser\r\nInclude the [mock helper][mock] in your test flow.\r\n\r\n[mock]: https://raw.github.com/jmendiara/ng-di/master/dist/mock.js\r\n\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"mock.js\"\u003e\u003c/script\u003e\r\n\u003c!-- mock.module and mock.inject are available --\u003e\r\n```\r\n\r\n## Development\r\n\r\nAfter cloning, the repository...\r\n\r\n**Install all dependencies**\r\n\r\n```bash\r\nnpm install \r\n```\r\n\r\nng-di uses grunt 0.4.x for building the browser version and for testing. You will need to have installed grunt-cli as global\r\n\r\n**Pass all test in browser and node.**\r\n\r\nRelies on Karma and assumes a PhantomJS(*) browser installed on your machine\r\n```bash\r\ngrunt test\r\n```\r\n\r\n**Build the browser version**\r\n\r\nCreates all browser compatible code on /dist directory\r\n```bash\r\ngrunt build\r\n```\r\n\r\n**Test and build**\r\n\r\n```bash\r\ngrunt \r\n```\r\n\r\n(*) After installing PhantomJS, add the executable to your path\r\n```bash\r\n#Add phantomJS to MacOSX PATH by editing ~/.bash_profile\r\nexport PHANTOMJS_BIN=/Applications/phantomjs-1.9.0-macosx/bin/phantomjs \r\n```\r\n\r\n## Aim of this project\r\nThe goal behind this project is closing the gap between the browser and node environments for developing testable libraries\r\nand applications that could be used in both environments.\r\n\r\nJust provide different implementations for those environment dependant code (Browser XMLHttpRequest vs. Node http) and reuse\r\nall the application code\r\n\r\nng-di isolates you from the dependency injection in environments, but you will have to deal with the CommonsJS/AMD/no-module \r\nproblem by yourself. Ideas are always welcome!\r\n\r\n## Release History\r\n\r\nng-di uses [semantic versioning](http://semver.org/)\r\n### v0.2.0 \r\n* Expose annotate function\r\n \r\n### v0.1.1\r\n* FIX compatibility with mocha in mocks\r\n\r\n### v0.1.0\r\n* Completely rewrite internals using commonsJS module.\r\n* Adding mocks for both environments\r\n\r\n#### BREAKING CHANGES\r\n* $utils is not exposed anymore. \r\n* Module 'di' is not registered by default\r\n* Removed lots of utility functions from being accesible. See [utils](lib/utils.js) for details.\r\n* Requiring in node does not need to recall `di`. Use: `var di = require('ng-di');`\r\n\r\n### v0.0.4 \r\n* Adding more utilities functions to the code\r\n \r\n### v0.0.3 \r\n* Adding more utilities functions to the code\r\n\r\n### v0.0.2 \r\n* new service in module `di` exposing `$utils` functions\r\n\r\n### v0.0.1 \r\n * First approach\r\n\r\n\r\n## License\r\nThis work is more-than-heavily based on AngularJS Dependency injection. All credits must go to the Angular Developers\r\nLicensed under the MIT license.\r\n\r\n\r\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jmendiara/ng-di/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmendiara%2Fng-di","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmendiara%2Fng-di","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmendiara%2Fng-di/lists"}