$获得了$ HTTP / $资源服务的属性? [英] $get property for a $http/$resource service?

查看:109
本文介绍了$获得了$ HTTP / $资源服务的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图找出是什么在这个code回事 - 我有一个 $资源服务,我使用的请求从Rails的后端,像数据

Trying to figure out what is going on in this code - I have a $resource service which I am using to request data from Rails backend, something like:

$scope.my_objects = my_objects_results.get(.... );

在视图中,我有一个 NG-重复这确实在my_objects一个 my_object 并在指令 my_object 有code等组成的一行:

In the view, I have an ng-repeat which does an my_object in my_objects and in a directive for my_object there is a line of code like:

 my_object.$get(successCallback);

我看来,这code是调用一个简单的HTTP GET为 my_object 。但我想,我不知道为什么?我所阅读文档的是,$得到的是一个服务的构造函数。但我无法找到什么的$获取属性的文件为$资源(​​或$ HTTP?)......东西会证实我所观察。

I appears that this code is calling a simple http get for my_object. But I guess I am not sure why? All the documentation I read is that the $get is the constructor function for a service. But I am having trouble finding documentation on what the $get property is for $resource (or $http?) ... something that would confirm what I am observing.

推荐答案

好吧,我想我发现,解释$得到W / R / t至$资源在这里的文档:

Ok, I think I found the documentation that explains $get w/r/t to $resource here:

http://www.angularjshub.com/examples/servercalls/resourceservice/

的要点是:

我们可以把分成两类方法:
  构造层次的方法和实例级的方法。他们全部送
  和接收JSON对象,但主要的区别在于
  构造层次的人在被返回的对象都可以
  $资源的构造,而实例级方法可用
  在资源的任何实例,即通过返回一个实例
  服务器或者与新的关键字在客户端上创建一个实例
  由$资源构造函数返回的对象。

We can divide the methods in two separate categories: constructor-level methods and instance-level methods. All of them send and receive JSON objects, but the main distinction is that the constructor-level ones are available in the object returned by the $resource constructor while the instance-level methods are available in any instance of resource, that is an instance returned by the server or an instance created on the client with the new keyword on the object returned by the $resource constructor.

每个资源实例都有基本的$ GET,$查询,$保存和删除$
  方法。他们相当于在其构造层次的对口
  它们的意义,但也有一些不同之处。

Every Resource instance has the basic $get, $query, $save and $delete methods. They're equivalent to their constructor-level counterparts in their meaning, but there are some differences.

我觉得这是基本的主要角文档以及,但它是那么明显。

I think this is basically on the main angular documentation as well, but it was less obvious.

这篇关于$获得了$ HTTP / $资源服务的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆