ng-annotate adds and removes AngularJS dependency injection annotations.
It is non-intrusive so your source code stays exactly the same otherwise.
No lost comments or moved lines. Annotations are useful because with them
you're able to minify your source code using your favorite JS minifier.

You can also use ng-annotate to rebuild or remove existing annotations.
Rebuilding is useful if you like to check-in the annotated version of your
source code. When refactoring, just change parameter names once and let
ng-annotate rebuild the annotations. Removing is useful if you want to
de-annotate an existing codebase that came with checked-in annotations

*ng-annotate works by using static analysis to identify common code patterns.
There are patterns it does not and never will understand and for those you
can use an explicit ngInject annotation instead, see section further down.

Then run it as ng-annotate OPTIONS <file>. The errors (if any) will go to stderr,
the transpiled output to stdout.

Use the --add (-a) option to add annotations where non-existing,
use --remove (-r) to remove all existing annotations,
use --add --remove (-ar) to rebuild all annotations.

Use the -o option to write output to file.

Provide - instead of an input <file> to read input from stdin.

Use the --sourcemap option to generate an inline sourcemap.

Use the --sourceroot option to set the sourceRoot property of the generated sourcemap.

Use the --single_quotes option to output '$scope' instead of "$scope".

Use the --regexp option to restrict matching further or to expand matching.
See description further down.

experimental Use the --rename option to rename providers (services, factories,
controllers, etc.) with a new name when declared and referenced through annotation.
Use it like this: --rename oldname1 newname1 oldname2 newname2

experimental Use the --plugin option to load a user plugin with the provided path,
0.9.x may change API). See plugin-example.js for more info.

For short forms it does not need to see the declaration of myMod so you can run it
on your individual source files without concatenating. If ng-annotate detects a short form
false positive then you can use the --regexp option to limit the module identifier.
Examples: --regexp "^myMod$" (match only myMod) or --regexp "^$" (ignore short forms).
You can also use --regexp to opt-in for more advanced method callee matching, for
example --regexp "^require(.*)$" to detect and transform
require('app-module').controller(..). Not using the option is the same as passing
--regexp "^[a-zA-Z0-9_\$\.\s]+$", which means that the callee can be a (non-unicode)
identifier (foo), possibly with dot notation (foo.bar).

ng-annotate follows references. This works iff the referenced declaration is
a) a function declaration or
b) a variable declaration with an initializer.
Modifications to a reference outside of its declaration site are ignored by ng-annotate.

You can prepend a function with /*@ngInject*/ to explicitly state that the function
should get annotated. ng-annotate will leave the comment intact and will thus still
be able to also remove or rewrite such annotations.

You can also wrap an expression inside an ngInject(..) function call. If you use this
syntax then add function ngInject(v) { return v } somewhere in your codebase, or process
away the ngInject function call in your build step.

You can also add the "ngInject" directive prologue at the beginning of a function,
similar to how "use strict" is used, to state that the surrounding function should get
annotated.

Use ngInject to support your code style when it's not in a form ng-annotate understands
natively. Remember that the intention of ng-annotate is to reduce stuttering for you,
and ngInject does this just as well. You don't need to keep two lists in sync. Use it!

ngInject may be particularly useful if you use a compile-to-JS language that doesn't
preserve comments.

The /*@ngInject*/, ngInject(..) and "ngInject" siblings have three cousins that
are used for the opposite purpose, suppressing an annotation that ng-annotate added
incorrectly (a "false positive"). They are called /*@ngNoInject*/, ngNoInject(..)
and "ngNoInject" and do exactly what you think they do.

Here follows some ngInject examples using the /*@ngInject*/ syntax. Most examples
works fine using the ngInject(..) or "ngInject" syntax as well.

x =/*@ngInject*/function($scope){};

obj ={controller:/*@ngInject*/function($scope){}};

obj.bar =/*@ngInject*/function($scope){};

=>

x =/*@ngInject*/["$scope",function($scope){}];

obj ={controller:/*@ngInject*/["$scope",function($scope){}]};

obj.bar =/*@ngInject*/["$scope",function($scope){}];

Prepended to an object literal, /*@ngInject*/ will annotate all of its contained
function expressions, recursively:

obj =/*@ngInject*/{

controller: function($scope){},

resolve:{data: function(Service){}},

};

=>

obj =/*@ngInject*/{

controller:["$scope",function($scope){}],

resolve:{ data:["Service",function(Service){}]},

};

Prepended to a function statement, to a single variable declaration initialized with a
function expression or to an assignment where the rvalue is a function expression,
/*@ngInject*/ will attach an $inject array to the function:

ngmin has been deprecated in favor of ng-annotate. In short:
ng-annotate is much faster, finds more declarations to annotate (including ui-router),
treats your source code better, is actively maintained and has a bunch of extra features
on top of that. A much more elaborated answer can be found in
"The future of ngmin and ng-annotate".

Migrating from ngmin:
ng-annotate -a - is similar to ngmin (use stdin and
stdout). ng-annotate -a in.js -o out.js is similar to ngmin in.js out.js. Grunt users
can migrate easily by installing
grunt-ng-annotate and replacing ngmin
with ngAnnotate in their Gruntfile. Scroll down for information about other tools.