Sanity checking with ng-strict-di
The ng-strict-di
directive is new and extremely simple to understand. When declaring the parent DOM node for your application, if ng-strict-di
is included in that element, functions without the minification-safe dependency injection syntax will fail to execute.
How to do it…
Using the ng-strict-di
directive is as simple as adding an extra attribute to your ng-app
node, as follows:
(app.js)
angular.module('myApp',[])
.controller('Ctrl', function($scope) {});
(index.html)
<div ng-app="myApp" ng-strict-di>
<div ng-controller="Ctrl"></div>
</div>
If you try to load the page in your browser, you will be greeted with the following error:
Error: [$injector:strictdi] function($provide) is not using explicit annotation and cannot be invoked in strict mode
Tip
JSFiddle: http://jsfiddle.net/msfrisbie/snqvypgL/
There's more…
The ng-strict-di
directive recognizing a minification-vulnerable application and consequently throwing on the brakes is for...