How to troubleshoot Angular JS Unknown Provider error in minified code

2.1k views Asked by At

While the app works in debug mode, when release mode switches on .NET bundles, I get the Unknown Provider error. The problem is there many sources (Bootstrap UI and other third-party controls besides application scripts). I fixed a couple of obvious initializers, but this error seems to refer to minified code, generic names:

http://errors.angularjs.org/1.2.21/$injector/unpr?p0=nProvider%20%3C-%20n

How do you troubleshoot something like that?

1

There are 1 answers

1
Mark Meyerovich On BEST ANSWER

The way to figure out the problem was to exclude one script file at a time from minification and to see whether the error goes away. The error was actually similar to the one in the question on unknown provider "aProvider <- a" error.

In my case there were several errors. The main one was due to the modal dialog controller, similar to the discussion about injecting modal controller dependencies. However it would only occur with minified code.

The suggestion to provide the controller in the modal options as a string did not work for me. But declaring controller with its dependencies did the trick:

var ModalInstanceCtrl = ['$scope', '$modalInstance', 'items', 
           function ($scope, $modalInstance, items) { ... }