Vanilla JS to Angular.js