AngularJs Minification Problems and Solutions

AngularJs Minification Problems and Solutions


In AngularJs, there are basically 3 ways to minify (inject dependencies) your angular projects and scripts.

If we are using inline or injector annotations in angular project then you don't wary over the projects minify problems. Its automatically handle all the minify problems.

In AngularJs, inline array annotations development techniques are most popular now days and you should avoid to use to implicit dependency injection in angular projects.

var app = angular.module('minifyApp', []);

Step -1.

In the first step, we can use the inline array annotations. i.e.
app.controller('MainCtrl', ["$scope", function ($scope) { }]); 


The above line of code handle the minification automatically.

Step -2.


In the second step, we can use the injector($inject) property annotations. i.e.
var mainCtrl = function ($scope) { });

mainCtrl.$inject = ['$scope'];

app.controller('mainCtrl', mainCtrl);

The above line of code handle the minification automatically.

Step -3.

In the 3rd step,  we can use the implicitly function parameter names. i.e.
app.controller('mainCtrl', function ($scope) { });

Need to avoid above line of code in AngularJs scripts and projects.

Warning!  :)
You never use to implicit dependency injection in your projects because It can be break your applications and projects.


Thank you very much for reading this post.(Anil Singh)


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^