Angular refactor

Refactored code to use AngularJS.
in general don't make any scope variables unless absolutely necessary