Skip to content

Commit 46d18e9

Browse files
committed
Merge pull request jakemmarsh#112 from jakemmarsh/fix-ng-annotate
add ngInject prologues and documentation, remove mangle option
2 parents 62ee503 + 5c4d27e commit 46d18e9

File tree

8 files changed

+19
-4
lines changed

8 files changed

+19
-4
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,16 @@ export default {
7777

7878
##### Dependency injection
7979

80-
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.
80+
Dependency injection is carried out with the `ng-annotate` library. In order to take advantage of this, a simple directive prologue of the format:
81+
82+
```js
83+
function MyService($http) {
84+
'ngInject';
85+
...
86+
}
87+
```
88+
89+
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.
8190

8291
---
8392

app/js/filters/example.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use strict';
22

33
function ExampleFilter() {
4+
45
return function(input) {
56
return input.replace(/keyboard/ig,'leopard');
67
};
8+
79
}
810

911
export default {

app/js/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ angular.module('app').config(require('./on_config'));
2929

3030
angular.module('app').run(require('./on_run'));
3131

32-
angular.bootstrap(document, ['app']);
32+
angular.bootstrap(document, ['app'], {
33+
strictDi: true
34+
});

app/js/on_config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
function OnConfig($stateProvider, $locationProvider, $urlRouterProvider) {
4+
'ngInject';
45

56
$locationProvider.html5Mode(true);
67

app/js/on_run.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
function OnRun($rootScope, AppSettings) {
4+
'ngInject';
45

56
// change page title based on state
67
$rootScope.$on('$stateChangeSuccess', (event, toState) => {

app/js/services/example.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
function ExampleService($http) {
4+
'ngInject';
45

56
const service = {};
67

gulp/tasks/browserify.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ function buildScript(file) {
5858
.pipe(gulpif(createSourcemap, buffer()))
5959
.pipe(gulpif(createSourcemap, sourcemaps.init()))
6060
.pipe(gulpif(global.isProd, streamify(uglify({
61-
mangle: false,
6261
compress: { drop_console: true }
6362
}))))
6463
.pipe(gulpif(createSourcemap, sourcemaps.write('./')))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-gulp-browserify-boilerplate",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"author": "Jake Marsh <[email protected]>",
55
"description": "Boilerplate using AngularJS, SASS, Gulp, and Browserify while also utilizing best practices.",
66
"repository": {

0 commit comments

Comments
 (0)