This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var allAccounts = Restangular.all("accounts"); | |
| // GET /accounts | |
| allAccounts.getList().then(function(accounts) { | |
| // Get /accounts/123/users considering 123 is the ID of accounts[0] | |
| accounts[0].getList("users").then(function(users) { | |
| // POST /accounts/123/users | |
| users.post({name: "Gonto"}) | |
| var oneUser = users[0]; | |
| oneUser.name = "Hey jude"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Restangular.all("accounts").getList().then(function(list) { | |
| console.log("Success"); | |
| }, function(err) { | |
| var response = err[0]; | |
| console.log(response.status) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "restangular", | |
| "description": "Restfull Resources service for AngularJS apps", | |
| "version": "0.5.3", | |
| "filename": "restangular.min.js", | |
| "homepage": "https://github.com/mgonto/restangular", | |
| "author": "Martin Gontovnikas <martin@gonto.com.ar>", | |
| "dependencies": {}, | |
| "devDependencies": { | |
| "grunt-cli": ">= 0.1.7", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "restangular", | |
| "version": "0.5.3", | |
| "main": "./dist/restangular.min.js", | |
| "description": "Restfull Resources service for AngularJS apps", | |
| "repository": { | |
| "type": "git", | |
| "url": "git://github.com/mgonto/restangular.git" | |
| }, | |
| "dependencies": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| module.exports = function(grunt) { | |
| // Project configuration. | |
| grunt.initConfig({ | |
| dirs: { | |
| dest: 'dist' | |
| }, | |
| bower: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var restangualrSpaces = Restangular.one("accounts",123).one("buildings", 456).all("spaces"); | |
| // This will do ONE get to /accounts/123/buildings/456/spaces | |
| restangularSpaces.getList() | |
| // This will do ONE get to /accounts/123/buildings/456/spaces/789 | |
| Restangular.one("accounts", 123).one("buildings", 456).one("spaces", 789).get() | |
| // POST /accounts/123/buildings/456/spaces | |
| Restangular.one("accounts", 123).one("buildings", 456).all("spaces").post({name: "New Space"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //GET /messages/123/archive | |
| Restangular.one("messages", 123).customGET("archive") | |
| //POST /messages/clear-all?param=param2 with body of {force: true} | |
| Restangular.all("messages").customPOST("clear-all", {param: "param2"}, {}, {force: true}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //In your app configuration (config method) | |
| RestangularProvider.setOnElemRestangularized(function(elem, isCollection, route) { | |
| if (!isCollection && route === "buildings") { | |
| // This will add a method called evaluate that will do a get to path evaluate with NO default | |
| // query params and with some default header | |
| // signature is (name, operation, path, params, headers, elementToPost) | |
| elem.addRestangularMethod('evaluate', 'get', 'evaluate', undefined, {'myHeader': 'value'}); | |
| } | |
| return elem; | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var restangualrSpaces = Restangular.one("accounts",123).one("buildings", 456).all("spaces"); | |
| // This will do ONE get to /accounts/123/buildings/456/spaces | |
| restangularSpaces.getList() | |
| // This will do ONE get to /accounts/123/buildings/456/spaces/789 | |
| Restangular.one("accounts", 123).one("buildings", 456).one("spaces", 789).get() | |
| // POST /accounts/123/buildings/456/spaces | |
| Restangular.one("accounts", 123).one("buildings", 456).all("spaces").post({name: "New Space"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Use LATEST folder to always get the latest version--> | |
| <script type="text/javascript" src="http://cdn.jsdelivr.net/restangular/latest/restangular.js"></script> | |
| <script type="text/javascript" src="http://cdn.jsdelivr.net/restangular/latest/restangular.min.js"></script> | |
| <!-- Or use TAG number for specific version --> | |
| <script type="text/javascript" src="http://cdn.jsdelivr.net/restangular/0.5.3/restangular.js"></script> | |
| <script type="text/javascript" src="http://cdn.jsdelivr.net/restangular/0.5.3/restangular.min.js"></script> |