Can I use either for a REST call ? Or is there some minor difference ? I have used both of them in my projects with no side effects,
Asked
Active
Viewed 4,898 times
0
-
1Yes...you can use either. If you have used them both please be more specific about what you want to know about them. Also please read http://stackoverflow.com/help/how-to-ask – charlietfl Jan 05 '16 at 02:58
-
4Possible duplicate of [AngularJS $http and $resource](http://stackoverflow.com/questions/13181406/angularjs-http-and-resource) – Phureewat A Jan 05 '16 at 03:23
-
1`$resource` is a wrapper library for `$http` to make `$http` easier to work with. In the end, `$http` is still being used, but you likely won't directly interact with it. – Claies Jan 05 '16 at 04:27
1 Answers
5
These are the main differences between $http and $resource:
$http:
- $http is for universal purpose. It is an Ajax call.
- $http is built into the AngularJS framework.
- $http is good for quick retrieval.
- $http is injected directly into an AngularJS controller by the developer.
For more details about $http refer: https://docs.angularjs.org/api/ng/service/$http
$resource:
- $resource wraps $http to use in RESTful web APIs.
- $resource needs to add the module separately.
- $resource is good for conditions slightly more complex than $http.
- $resource does not allow us to do much with data once it is consumed in the application. It is in the final state when it is delivered to the HTML DOM. The data are the same that the $http method will receive.
For more details about $resource refer: https://docs.angularjs.org/api/ngResource/service/$resource

Community
- 1
- 1

Thangadurai
- 524
- 1
- 9
- 20