What is the difference between of using Restangular over ngResource ?
Key differences between Restangular and ngResource:
- Instead of doing the “magic” filling of objects like $resource, Restangular uses promises(promise represents the eventual results of an operation. You’ll use a promise to specify what to try when an operation succeeds or fails).
- Restangular doesn’t have a problem with trailing slashes, additional: within the URL, escaping information, expecting only arrays for getting lists, etc.
- Restangular supports all HTTP methods whereas, $resource supports only ‘GET’, ‘POST’, ‘PUT’, ‘DELETE’.
- Restangular supports Etag of the box. You do not need to do anything. ETags and If-None-Match are going to be utilized in all of your requests.
- In Restangular, if you receive from the server some item that features a link to itself, you’ll use that to question the server rather than writing the URL manually.
- Each time you would like to try to an invitation, you’ll just roll in the hay using the thing that was returned by Restangular. you do not get to create a replacement object for this. But, in while using $resource you’ve got to make one $resource object per request.
- With $resource, you would like to write down the URL Template. In Restangular, you do not write any URLs. you only write the name of the resource you would like to fetch and that is it.
- If you’ve got Nested RESTful resources, Restangular can handle them for you. you do not need to know the URL, the path, or anything to try to all of the HTTP operations you would like.
In a nutshell, we will say that besides the extra features and therefore the promise based approach, Restangular also can handle all of your URLs, in order that you don’t need to know anything about them.