Using rest api from angularjs with $resource