Chapter 10 ■ Deployment ConsiDerations
This is by no means the only way to do error handling, and you might want to consider an approach that will
work well for your particular project. In some scenarios, it might well be better to log to the end user’s device, though
this is simply food for thought. I think it is fair to say that any approach at all is always better than the all-too-common
no plan whatsoever.
■ Caution if you do choose to log information to the user’s device, you need to consider the fact that this comes with
some risk. the information is potentially accessible to other users, unless you put safeguards in place.
Hide Unprocessed Templates
Your AngularJS application needs to download your application scripts and the AngularJS scripts before it can go
about its work. As you know, one aspect of this work is template processing; a job that can be done only once all of
the required files are fully downloaded to the user’s device. It is possible, particularly if your files are taking some time
to download, that your end users will see the AngularJS interpolation expressions in their raw unprocessed form, as
shown in Figure 10-1. This rather ugly looking, and potentially confusing, eyesore may only last for a split second or
so, but it might well be something that you want to avoid,
Figure 10-1. Unprocessed templates are an eyesore!
The ng-cloak directive lets you hide (through the use of display: none) parts of the DOM tree until AngularJS
is ready to process the whole page and make it live. You can hide a specific portion of the DOM tree, as we do in
Listing 10-11.
Listing 10-11. Hiding a specific portion of the DOM tree
Hello, {{name}}!
It's great to see you again, you haven't logged in since {{lastLoggedIn}}
Alternatively, you can hide the entire page by using ng-cloak at a higher level in the DOM tree. In Listing 10-12
we apply ng-cloak on the controller element itself, thereby hiding everything in one fell swoop.