I am trying to minify my js files in my angular app. I know there is some pbs when it comes to dependency injection and minification but I felt like I followed the best practices I found on the internet.
Here is the structure of my code:
My provider:
function myPvdr() {
this.getUrl = function() {
return 'http://some/api/call';
};
this.$get = function($q, $http) {
var self = this;
return {
getData: function(points) {
var d = $q.defer();
$http({
method: 'GET',
url: self.getUrl(),
cache: true
}).success(function(data) {
d.resolve(data);
}).error(function(err) {
d.reject(err);
});
return d.promise;
}
}
}
}
My Controller:
function myCtrl($scope, MyProvider, localStorageService) {
// some code
}
My Module:
angular.module('myApp', ['LocalStorageModule', 'ngAnimate'])
.provider('MyProvider', myPvdr)
// Loading controllers into the module
.controller('myCtrl', ['$scope', 'MyProvider', 'localStorageService', myCtrl])
It works fine when unminified. But after using the uglify task from grunt I get the following error printed to the console:
Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-rc.2/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20MyProvider
What am I doing wrong?