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

Commenting JSON files


This isn't quite an AngularJS hack per se, but when you are writing JSON configuration files (for example, in your Grunt configuration, Bower package definition, or npm package definition), you might find that you forgot the purpose of a line. Inconveniently, JSON does not support formal comments, but there are some clever (but highly controversial) workarounds that can be used with a pinch.

How to do it…

If the JSON file is parsed in a certain way, you can take advantage of that by allowing the data format to bleed outside the boundaries of the JSON specification.

Ignored properties

If you know that a section of JSON won't be exhaustively parsed, that is, there is a defined set of keys that it will examine, then the easiest route is to just incorporate a property that the program will ignore. This can be done as follows:

(package.json)

{
  "name": "playerApp",
  "version": "1.0.0",
  "_comment_devDependencies": "External test, build, or documentation framework components...