Refactor: use  in AngularJS for api