Refactored logic for code reuse.
Formatting.
ng app is on the main script tag.
Added back accidentally deleted file.