且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AngularJS $ http和$资源

更新时间:2023-01-23 18:07:52

$ HTTP 是通用的AJAX。在大多数情况下,这是你使用什么。随着 $ HTTP 你将要制定 GET POST 删除手动输入电话和处理他们在自己返回的对象。

$http is for general purpose AJAX. In most cases this is what you'll be using. With $http you're going to be making GET, POST, DELETE type calls manually and processing the objects they return on your own.

$资源包裹 $ HTTP 在REST风格的Web API使用的情况。

$resource wraps $http for use in RESTful web API scenarios.

概而言之:RESTful Web服务将是服务,一个端点为基于HTTP的方法,如 GET 与数据类型进行不同的数据类型, POST PUT 删除等,所以有 $资源,你可以调用一个 GET 来获取资源为JavaScript对象,然后改变它,并将其发送回以 POST ,或甚至删除删除

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 a GET to get the resource as a JavaScript object, then alter it and send it back with a POST, or even delete it with DELETE.

...如果是有道理的。

... if that makes sense.