什么是使用Restangular超过ngResource的优势在哪里? [英] What is the advantage of using Restangular over ngResource?

查看:113
本文介绍了什么是使用Restangular超过ngResource的优势在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ngResource 似乎很简单的实施与...事情

ngResource already seems really simple to implement things with...

有哪些优势/使用的缺点 Restangular 过的 ngResource

What are the Advantages / Disadvantages of using Restangular over ngResource?

1.1.3 $资源将返回承诺,并可以使用的形式实现<一个href=\"http://stackoverflow.com/questions/16429832/callback-after-async-foreach-angularjs/16447884#16447884\">latest PR提交 。将未来的支持提供给 $资源来支持Restangular做额外的动词?如果出现这种情况Restangular好像它会消失,并成为irrelivant。

1.1.3 $resource will return promises and can be implimented using latest PR commit. Will future support be offered to $resource to support additional verbs that Restangular does? And if that happens Restangular seems like it will disappear and become irrelivant.

推荐答案

我Restangular的创造者。

I'm the creator of Restangular.

我已经创建与反对$资源的差异自述的部分。您可以检查出来这里的https://github.com/mgonto/restangular/blob/master/README.md#differences-with-resource

I've created a section on the README with the differences against $resource. You can check them out here https://github.com/mgonto/restangular/blob/master/README.md#differences-with-resource

不管怎样,作为一个总结,除了附加功能和基于承诺的方式,这个想法是,Restangular也可以处理所有网址,让你不必知道他们什么。

Anyway, as a sum up, besides the additional features and the promise based approach, the idea is that Restangular can also handle all of your URLs, so that you don't have to know anything about them.

假设你有这样的事情车型:/用户/ 123 /车/ 456

Suppose that you have something like this for cars : /users/123/cars/456

在$资源,你必须手动构建URL,你也不得不手动构造$资源对象这一点。 Restangular以记忆的网址,可以帮助你在这。

In $resource, You'd have to construct that URL manually and you'd also have to construct the $resource object for this manually. Restangular helps you in this by "remembering" the URLs.

所以,如果你在某个地方做

So if you do in some place

Restangular.one("users", 123).get().then(function(user) {
  $scope.user = user;
});

// Some other code

//Automatically does the request to /users/123/cars as it remembers in which object you're asking it.
$scope.user.getList('cars')

希望这有助于!

这篇关于什么是使用Restangular超过ngResource的优势在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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