I have some web services that I want to call. $resource or $http, which one should I use?
$resource: https://docs.angularjs.org/api/ngResource/service/$resource
$http: https://docs.angularjs.org/api/ng/service/$http
After I read the two above API pages I am lost.
Could you please explain to me in plain English what is the difference and in what situation should I use them? How do I structure these calls and read the results into js objects correctly?
$httpis for general purpose AJAX. In most cases this is what you’ll be using. With$httpyou’re going to be makingGET,POST,DELETEtype calls manually and processing the objects they return on your own.$resourcewraps$httpfor use in RESTful web API scenarios.Speaking VERY generally: A RESTful web service will be a service with one endpoint for a data type that does different things with that data type based on HTTP methods like
GET,POST,PUT,DELETE, etc. So with a$resource, you can call aGETto get the resource as a JavaScript object, then alter it and send it back with aPOST, or even delete it withDELETE.… if that makes sense.