refactoring AngularJS code to be minifier-safe