Minify javascript files help you reduce download file size and load your site faster.
If you got an error 'Uncaught Error: [$injector:unpr]' with angularjs after deployment, you can fix the following.
(function () {
'use strict';
var app = angular.module('app', [
// Angular modules
'ngRoute', 'ui.bootstrap'
]);
app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
}]);
})();
instead of writing
(function () {
'use strict';
var app = angular.module('app', [
// Angular modules
'ngRoute', 'ui.bootstrap'
]);
app.config(function ($routeProvider, $locationProvider) {
});
})();
Try to add '$routeProvider', '$locationProvider' to your function as a name, similar $scope, $http...etc in controller, service, factory, directive or you can use $inject as shows below.
(function () {
'use strict';
angular
.module('app')
.service('accountService', accountService);
accountService.$inject = ['$http'];
function accountService($http) {
}
})();
When minifying your code, it will minify all code by replacing the variable name
controller : function($scope) {}
minified
controller : function(e) {}
You should use
controller : ["$scope", function($scope) { ... }]
or using $inject
accountController.$inject = ['$scope', '$uibModal', 'toaster', 'companyService', 'accountService'];