Port from jquery to angular js