This is the stack trace when I use angular.js:
[$injector:unpr] Unknown provider: editorPopupManagerProvider <- editorPopupManager <- libStateManager <- libInjectionManager
.2.2/$injector/unpr?p0=editorPopupManagerProvider%20%3C-%20editorPopupManager%20%3C-%20libStateManager%20%3C-%20libInjectionManager
And this is the stack trace when I use angular.min.js:
[$injector:unpr] .2.2/$injector/unpr?p0=editorPopupManagerProvider%20%3C-%20editorPopupManager%20%3C-%20libStateManager%20%3C-%20libInjectionManager
This is just a simple example but sometimes the minified error doesn't help even a bit.
I expect the first stack trace in both cases: When I use angular.js and angular.min.js. I don't have a problem in the code that led to this exception. I made it on purpose to demonstrate the problem I have with angular.min.js minifying the stack trace and making it really hard to understand. If the reason it does that is to avoid end users to see the stack trace, I understand. But I need the normal-readable stack trace in order to send it to a logging server.
This is the stack trace when I use angular.js:
[$injector:unpr] Unknown provider: editorPopupManagerProvider <- editorPopupManager <- libStateManager <- libInjectionManager
http://errors.angularjs/1.2.2/$injector/unpr?p0=editorPopupManagerProvider%20%3C-%20editorPopupManager%20%3C-%20libStateManager%20%3C-%20libInjectionManager
And this is the stack trace when I use angular.min.js:
[$injector:unpr] http://errors.angularjs/1.2.2/$injector/unpr?p0=editorPopupManagerProvider%20%3C-%20editorPopupManager%20%3C-%20libStateManager%20%3C-%20libInjectionManager
This is just a simple example but sometimes the minified error doesn't help even a bit.
I expect the first stack trace in both cases: When I use angular.js and angular.min.js. I don't have a problem in the code that led to this exception. I made it on purpose to demonstrate the problem I have with angular.min.js minifying the stack trace and making it really hard to understand. If the reason it does that is to avoid end users to see the stack trace, I understand. But I need the normal-readable stack trace in order to send it to a logging server.
Share Improve this question edited Jan 15, 2014 at 15:58 Shaul Amran asked Jan 14, 2014 at 9:37 Shaul AmranShaul Amran 491 silver badge3 bronze badges 2- 1 What is your question? What do you expect? Use the unminified version in development to make it easier to debug. – James Allardice Commented Jan 14, 2014 at 9:40
-
Even I face the problem, use this Dependency Annotation style
someModule.factory('greeter', ['$window', function(renamed$window) { ... }]);
in entire application. Problem is in where you have definededitorPopupManagerProvider
. Additionally can you posteditorPopupManagerProvider
code? – Satpal Commented Jan 14, 2014 at 9:43
2 Answers
Reset to default 3Your unknown provider name is probably being manipulated/mangled by the minifier, thus you need to use the following syntax to correct it:
myApp.controller('MyCtrl' ['$scope', function ($scope) {
// do stuff with '$scope'
}]);
Note how the function is wrapped in an Array, this keeps the naming conventions of your dependencies so they can safely be remapped as Strings are not mangled:
myApp.controller('MyCtrl' ['$scope', function (a) {
// do stuff with 'a'
}]);
Which you can then add your other dependencies (they need to appear in the order as they're specified):
myApp.controller('MyCtrl' ['$scope', 'MyService', function ($scope, MyService) {
// do stuff...
}]);
In case, that you do use the array declaration for your controllers, this would most likely be of some of your Directive declarations. Usually we do this:
.controller('MyGreatCtrl',
[ '$scope','$stateParams', // even minified version does is correctly injected
function($scope , $stateParams ,) {
...
And the above code will work correctly, even if minified.
But, what we should do the same way - is the Directive
declaration. We can do it like this (wrong, problems when minified):
.directive('myGreatDirective',
[function () {
var directive =
{
restrict: 'E',
...
controller: function ($scope , $element , $attrs) {
...
};
}],
};
return directive;
While this would be the correct way:
.directive('myGreatDirective',
[function () {
var directive =
{
restrict: 'E',
...
// the Array declaration also here
controller: ['$scope','$element','$attrs',
function ($scope , $element , $attrs) {
...
};
}],
};
return directive;
And the link to more details Dependency Injection
Honestly, that was my issue ...