diff --git a/README.md b/README.md index ba67a8bf..fc9b1be9 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,16 @@ export default { ##### Dependency injection -Dependency injection is carried out with the `ng-annotate` library. The Gulp tasks will take care of injecting any dependencies, requiring you only to specify the dependencies within the function call and nothing more. +Dependency injection is carried out with the `ng-annotate` library. In order to take advantage of this, a simple directive prologue of the format: + +```js +function MyService($http) { + 'ngInject'; + ... +} +``` + +needs to be added at the very beginning of any Angular functions/modules. The Gulp tasks will then take care of adding any dependency injection, requiring you to only specify the dependencies within the function parameters and nothing more. --- diff --git a/app/js/filters/example.js b/app/js/filters/example.js index 759584f8..661bda4e 100644 --- a/app/js/filters/example.js +++ b/app/js/filters/example.js @@ -1,9 +1,11 @@ 'use strict'; function ExampleFilter() { + return function(input) { return input.replace(/keyboard/ig,'leopard'); }; + } export default { diff --git a/app/js/main.js b/app/js/main.js index fb09a57c..64ece7a2 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -29,4 +29,6 @@ angular.module('app').config(require('./on_config')); angular.module('app').run(require('./on_run')); -angular.bootstrap(document, ['app']); +angular.bootstrap(document, ['app'], { + strictDi: true +}); diff --git a/app/js/on_config.js b/app/js/on_config.js index 0b22588a..9befdb7b 100644 --- a/app/js/on_config.js +++ b/app/js/on_config.js @@ -1,6 +1,7 @@ 'use strict'; function OnConfig($stateProvider, $locationProvider, $urlRouterProvider) { + 'ngInject'; $locationProvider.html5Mode(true); diff --git a/app/js/on_run.js b/app/js/on_run.js index 5642b4c8..e49dc2f8 100644 --- a/app/js/on_run.js +++ b/app/js/on_run.js @@ -1,6 +1,7 @@ 'use strict'; function OnRun($rootScope, AppSettings) { + 'ngInject'; // change page title based on state $rootScope.$on('$stateChangeSuccess', (event, toState) => { diff --git a/app/js/services/example.js b/app/js/services/example.js index ddbe0fbd..e388a3cf 100644 --- a/app/js/services/example.js +++ b/app/js/services/example.js @@ -1,6 +1,7 @@ 'use strict'; function ExampleService($http) { + 'ngInject'; const service = {}; diff --git a/gulp/tasks/browserify.js b/gulp/tasks/browserify.js index 333e3b35..a40f16cb 100644 --- a/gulp/tasks/browserify.js +++ b/gulp/tasks/browserify.js @@ -58,7 +58,6 @@ function buildScript(file) { .pipe(gulpif(createSourcemap, buffer())) .pipe(gulpif(createSourcemap, sourcemaps.init())) .pipe(gulpif(global.isProd, streamify(uglify({ - mangle: false, compress: { drop_console: true } })))) .pipe(gulpif(createSourcemap, sourcemaps.write('./'))) diff --git a/package.json b/package.json index bd99acd0..82d3f3b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angularjs-gulp-browserify-boilerplate", - "version": "1.0.3", + "version": "1.1.0", "author": "Jake Marsh ", "description": "Boilerplate using AngularJS, SASS, Gulp, and Browserify while also utilizing best practices.", "repository": {