Disabling implicit dependency injection in AngularJS

I am trying to debug a missing provider in a Big-ish AngularJS project. The error is the missing "dProvider". This only happens in a version of the code that has been minimized, which makes sense because we do not have controllers, factories, or 'd' services. I am having trouble finding what causes this, and searching by abbreviated code for things like function(a,b,c,d)nothing else has brought. Is there a way to force only explicit dependency into Angular? It seems that if I could force this, I could catch the problem in the dev environment.

+3
source share
3 answers

Yippee! Since Angular 1.3.1 you can disable implicit dependency injection!

From the code using the strictDiconfig property :

angular.bootstrap(document, ['myApp'], {
    strictDi: true
});

Or from a template using the directive ng-strict-di:

<html ng-app="myApp" ng-strict-di>
+7
source

Wow of that.

This controller / service is probably defined as

app.controller('myCtrl', function($scope){
     ...
})

instead of safer

app.controller('myCtrl', ['$scope', function($scope){
    ...
}])

I don’t have a stupid answer, but maybe you can look for a 'function (and if you are lucky you will find the culprit. If something like this does not work, the source cards will probably go.

0
source

I finished selectively commenting on parts of my html until I figured out where the problem was. Turns out it was an angular -ui-bootstrap problem .

0
source

All Articles