$resource
is simply an abstraction over $http
with the idea that the API is convenient to use for RESTful endpoints. There is nothing $resource
can do that can not be written using $http
. A way to write the above in a factory leveraging $http
may include...
// assumption that API_LINK is an injectable constant
.factory('MyService', function(API_LINK, $http) {
function changePassword(params) {
return $http.put(API_LINK +'/api/users/', params);
}
function get(id) {
return $http.get(API_LINK +'/api/users?id=' + id);
}
return {
changePassword: changePassword,
get: get
}
});
with the following usage...
.controller('ctrl', function($scope, MyService) {
MyService.get('me').then(function(response) {
// ...
});
MyService.changePassword({ controller: 'password' }).then(function(response) {
// ...
});
});
If you need to take total control of your factory functions with involved promise resolution, I would suggest checking out the AngularJS $q API.