Resolving AngularJS minimization / obfuscation issues

AngularJs uses Dependency Injection (DI) to supply objects/variables during configuration.
Variables that begin with the $ character tend to be injected, therefore if a minimizor and/or obfuscater changes the variable name, the DI will not be performed.

This Angular Crash Course provides a detailed intro on AngularJS.

This blog details a common solution to the problems arising from minimization / obfuscation.

The Problem

Taking the example from the Angular Crash Course blog:

If this code is minimized / obfuscated the variable $scope will have it’s name changed to ‘a’ or ‘b’ or something resulting in the AngularJS DI not occurring hence, the angularJS app is not initialized.

The solution

Name the argument as so:

That’s it.

There is more detail here (along with a similar solution to a slightly different scenario):

This blog is based on pkozlowski.opensource ‘s stack overflow answer here:


Questions or comments  always welcome……