关闭AngularJS中的隐式依赖注入

xdh*_*ore 3 javascript dependency-injection angularjs

我正在尝试在大型AngularJS项目中调试缺少的提供程序.错误是缺少'dProvider'.它只发生在缩小的代码版本上,这是有道理的,因为我们没有'd'控制器,工厂或服务.我无法找到造成这种情况的原因,并在缩小的代码中搜索function(a,b,c,d)尚未产生任何结果的内容.有没有办法强制只在Angular中显式依赖注入?好像我可以强迫这个,我可以在开发环境中发现问题.

diz*_*l3d 7

yippee的!从Angular 1.3.1开始,您可以关闭隐式依赖注入!

从代码中,使用strictDiconfig属性:

angular.bootstrap(document, ['myApp'], {
    strictDi: true
});
Run Code Online (Sandbox Code Playgroud)

或者从模板,使用ng-strict-di指令:

<html ng-app="myApp" ng-strict-di>
Run Code Online (Sandbox Code Playgroud)