0

I'm getting the classic "eProvider <- e" upon minifying my angular code; obviously I recognize this as the issue when you don't specify modules to inject, e.g.:

angular.module("myModule").controller('MyCtrl', function ($scope, Organization, organizations) {});

But the problem is, I never write my angular code like that, specifically to avoid this issue. In fact, I can't seem to replicate it locally; only on Heroku (I'm using rails 4 and letting Rails's asset pipeline take care of minification).

Any thoughts on how I can go about finding out where this problem is happening? I have dozens of files, so it'd be tedious to go through each of them.

If it matters, I'm also using coffeescript.

eragone
  • 555
  • 1
  • 4
  • 16
  • I found a solution for debugging this issue on [this other SO question](http://stackoverflow.com/questions/23480591/debugging-unknown-provider-in-minified-angular-javascript/25126490#answer-25126490). – yourdeveloperfriend Aug 04 '14 at 19:56

1 Answers1

0

AngularJS uses parameter names as the names of the instances to inject, so when minifiers go over this and change them to a, b, and so on, AngularJS fails to inject the instances. For this reason, AngularJS supports an alternative way of specifying injected parameters, by specifying the names in an array. It certainly doesn't look right, because you define the names twice, but it works:

angular.module("myModule")
.controller("MyCtrl", function ($scope, Organization, organizations) { /* ... */ });

vs.

angular.module("myModule")
.controller("MyCtrl", ["$scope", "Organization", "organizations", function ($scope, Organization, organizations) { /* ... */ }]);

See A note on minification.

Steve Klösters
  • 9,427
  • 2
  • 42
  • 53
  • Yes, that's what I was saying - I am completely aware and understand this concept, and thus I always utilize the latter method you stated. But the problem is it seems somewhere in my code I did not use it correctly, or have otherwise mistyped something, and am looking for a tool that might help me figure out where that is, or another method of finding the problem. – eragone Aug 09 '13 at 20:15