Book Image

AngularJS Web application development Cookbook

By : Matthew Frisbie
Book Image

AngularJS Web application development Cookbook

By: Matthew Frisbie

Overview of this book

Packed with easy-to-follow recipes, this practical guide will show you how to unleash the full might of the AngularJS framework. Skip straight to practical solutions and quick, functional answers to your problems without hand-holding or slogging through the basics. Avoid antipatterns and pitfalls, and squeeze the maximum amount out of the most powerful parts of the framework, from creating promise-driven applications to building an extensible event bus. Throughout, take advantage of a clear problem-solving approach that offers code samples and explanations of components you should be using in your production applications.
Table of Contents (17 chapters)
AngularJS Web Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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

There's more…

The ng-strict-di directive recognizing a minification-vulnerable application and consequently throwing on the brakes is for...