Angular.js module dependency injection.
It inject into a main module file that requires all your modules as a dependency.
- Adding a new module
- Removing a module
- 3rd party modules
- Data entry:
- example-1.js
angular.module('myGlobalApp', []);
- example-2.js
(function() { 'use strict'; angular.module('myGlobalApp', ['myModule']) })()
- example-3.js
(function() { 'use strict'; angular.module('myGlobalApp', [ 'myModule' ]) })()
npm install gulp-ng-modules --save-dev
var gulp = require('gulp');
var ngModules = require('gulp-ng-modules');
gulp.task('inject:modules', function() {
return gulp.src(['./app.js'])
.pipe(ngModules({name: 'myGlobalApp'}))
.pipe(gulp.dest('./dist'))
})
Type: string
required
The name of the module to create.
Type: array
optional
List of additional modules to include.
Type: array
optional
List of additional modules to exclude.
Type: function
optional
Create a custom output file
Check out the example directory: gulpfile.js
This is how the generated gulp-ng-modules.js will look like after
(function () {
'use strict';
angular.module('myGlobalApp', ['another.module', 'ui.router']);
})();