Refactor to use ngResource on a REST api