Your angular error is because you haven't setup your controller properly for minification.
registrationModule.controller('EstimatesCtrl',[ // notice the array brackets
'$scope', '$http', '$rootScope', // annotated with injected dependencies
function ($scope, $http, $rootScope) {
// etc.
}
] // be sure to close the array
);
When you minify angular doesn't know what to inject. Here's what your controller is when it's minified:
registrationModule.controller("EstimatesCtrl", function(n, t, i) {
t.get("Portal/Estimates").success(function(t) {
n.estimates = t
}).error(function(n) {
console.log(n)
});
n.viewEstimate = function(n) {
i.estimate = n
};
n.currentPage = 0;
n.pageSize = 20;
n.data = t.get("Portal/Estimates").success(function(t) {
n.estimates = t
}).error(function(n) {
console.log(n)
});
n.numberOfPages = Math.ceil(n.data.length / n.pageSize);
n.resetFilter = function() {
$route.reload()
}
});
The way AngularJS determines what to inject into your function is by taking the function and calling toString()
, then parsing out the names of the parameters. It's failing here because you don't have services called n
, t
, or i
.
by calling it with the array of injector-annotated dependencies, it would become:
registrationModule.controller("EstimatesCtrl", ['$scope', '$http', '$rootScope', function(n, t, i) {
// etc
}]);
Now, n == $scope
, t == $http
and $rootScope == i
. Since minifying code doesn't mangle strings, AngularJS knows what registered services need to get injected.
edit: I forgot to mention.. this needs to be done anywhere there is dependency injection. Check out the dependency injection documentation for more info.