I am using AngularJS $resource
to list, create, and update resources and it works fine. For example:
getFoo = (fooId) => {
const Foo = $resource("api/foos/:fooId);
return Foo.get({fooId});
};
This returns a Foo
instance that has a Foo.$promise
I can use to see when the request finishes.
But what if I want to delete a Foo?
deleteFoo = (fooId) => {
const Foo = $resource("api/foos/:fooId);
return Foo.delete({fooId});
};
All the examples I can find show Foo.delete({fooId})
, but never tell what it returns. How can I get a promise to know when deletion is successfull?
Does Foo.delete({fooId})
return a Foo
$resource with a Foo.$promise
, just like get()
? But that would be odd to have a resource of a thing I've just deleted. Does it return the $promise
itself? Does it return the underlying $http
object?
In short, how can I get a promise from Foo.delete({fooId})
to know when deletion has been successful?