Refactored all javascript into angular controllers