0.0.5 • Published 9 years ago

gulp-ng-register v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

gulp-ng-register

npm Travis Code Climate Code Climate npm npm

David David

Installation

$ npm install gulp-ng-register

Description

This gulp plugin can be used to automatically require and register Angular controller, directive and service modules.
All files provided by gulp.src() will be required and registered in your Angular app.
Modules are required to export a name property and one of the following:

  • controller
  • directive
  • service

It will generate a register.js file at the provided location by gulp.dest().
Require this file from your Angular app:

var app = angular.module('MyApp', []);

require('./register')(app);

Usage

var gulp = require('gulp');
var ngRegister = require('gulp-ng-register');

gulp.task('register', function(){
  return gulp.src('app/client/**/*.{controller,directive,service}.js')
    .pipe(ngRegister())
    .pipe(gulp.dest('/app/client'));
});

Options

You can pass a file name to ngRegister() if you want.

Examples

Controller

exports.name = 'MyController';
exports.controller = /*@ngInject*/ function MyController($scope, $http){
	// TODO: implement your controller
};

Directive

exports.name = 'myDirective';
exports.directive = /*@ngInject*/ function inject(){
	return {
		restrict: 'E',
	    scope: {
	      info: '=info'
	    },
	    templateUrl: 'my-template.html'
	};
};

Service

exports.name = 'myService';
exports.service = /*@ngInject*/ function inject(){
	return function add(x, y){
		return x + y;
	};
};

Test

$ npm install -g mocha  
$ mocha

Author

marc1404

License

MIT