add debug mode and state management for AngularJS