Put entire JS inside angular controller