Angular refactor

Refactored code to use AngularJS.