Fix error '$digest already in progress' in certain cases.

For reference:
-
http://stackoverflow.com/questions/12729122/prevent-error-digest-already
-in-progress-when-calling-scope-apply
- http://stackoverflow.com/a/14838239