Skip to content

Commit

Permalink
Merge pull request #112 from jakemmarsh/fix-ng-annotate
Browse files Browse the repository at this point in the history
add ngInject prologues and documentation, remove mangle option
  • Loading branch information
jakemmarsh committed Nov 19, 2015
2 parents 62ee503 + 5c4d27e commit 46d18e9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
2 changes: 2 additions & 0 deletions app/js/filters/example.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';

function ExampleFilter() {

return function(input) {
return input.replace(/keyboard/ig,'leopard');
};

}

export default {
Expand Down
4 changes: 3 additions & 1 deletion app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
1 change: 1 addition & 0 deletions app/js/on_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

function OnConfig($stateProvider, $locationProvider, $urlRouterProvider) {
'ngInject';

$locationProvider.html5Mode(true);

Expand Down
1 change: 1 addition & 0 deletions app/js/on_run.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

function OnRun($rootScope, AppSettings) {
'ngInject';

// change page title based on state
$rootScope.$on('$stateChangeSuccess', (event, toState) => {
Expand Down
1 change: 1 addition & 0 deletions app/js/services/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

function ExampleService($http) {
'ngInject';

const service = {};

Expand Down
1 change: 0 additions & 1 deletion gulp/tasks/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('./')))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-gulp-browserify-boilerplate",
"version": "1.0.3",
"version": "1.1.0",
"author": "Jake Marsh <[email protected]>",
"description": "Boilerplate using AngularJS, SASS, Gulp, and Browserify while also utilizing best practices.",
"repository": {
Expand Down

0 comments on commit 46d18e9

Please sign in to comment.