10

I need to better understand the difference between $http and $resource and when to use each

yar1
  • 1,331
  • 2
  • 15
  • 26
  • 1
    I know that basically $http is a wrapper for xmlHTTPRequest (aka AJAX) like jQuery's $ajax and that $resource is supposed to be more REST-specific but I don't really get how... – yar1 Apr 09 '13 at 09:00
  • 3
    possible duplicate of [AngularJS $http and $resource](http://stackoverflow.com/questions/13181406/angularjs-http-and-resource) – Max Jul 29 '14 at 18:49

2 Answers2

9

From the $resource docs:

A factory which creates a resource object that lets you interact with RESTful server-side data sources.

The returned resource object has action methods which provide high-level behaviors without the need to interact with the low level $http service.

$resource is a higher level service than $http.

manojlds
  • 290,304
  • 63
  • 469
  • 417
3

$resource is built on top of $http.

$http is normal ajax, it can be used for any form of web service.

$resource is specifically for RESTful service.

More details on this

AngularJS $http and $resource

Community
  • 1
  • 1
Tim Hong
  • 2,734
  • 20
  • 23