ng-ioc

0.1.1 • Public • Published

ng-ioc

IoC for AngularJS (1.x) modules.

This package automatically configures an AngularJS module based on file extensions in the provided directory.

Note that ng-ioc is intended to be used in Webpack-style environments, as it uses require.context to search for injectables.

Example setup:

var app = angular.module('my-app', []);
require('ng-ioc')(app, __dirname);
 
angular.element(() => angular.bootstrap(document, ['app']));
 
// BOOM! Everything's ready to go.

The above configuration simply searches the current path for AngularJS injectables. In order to actually add parts to the module, denote the file with a .[type].js extension.

Example (my-app.service.js):

module.exports = function($window)
{
    $window.alert('Example service');
}

Typical file layout:

  • component
    • example
      • example.component.js
      • example.html
  • config
    • example.config.js
  • service
    • example.service.js
  • main.js

Injectables are named by the name of the value (usually a function) exported by the file, or else the camelized file name (excluding the extension).

I hope you find this useful, and please feel free to contribute!

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i ng-ioc

    Weekly Downloads

    1

    Version

    0.1.1

    License

    none

    Last publish

    Collaborators

    • rvanasa