Skip to content

Instantly share code, notes, and snippets.

@mgonto
Created April 19, 2013 19:29
Show Gist options
  • Select an option

  • Save mgonto/5422621 to your computer and use it in GitHub Desktop.

Select an option

Save mgonto/5422621 to your computer and use it in GitHub Desktop.
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";
// PUT /accounts/123/users/4556
oneUser.put()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment