What is the advantage of using Restangular over ngResource?

Dan Kanze picture Dan Kanze · May 15, 2013 · Viewed 39.2k times · Source

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

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

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.

Answer

mgonto picture mgonto · May 23, 2013

I'm the creator of Restangular.

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

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.

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

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')

Hope this helps!