Skip to content

Instantly share code, notes, and snippets.

@bitrut
Last active December 29, 2015 13:19
Show Gist options
  • Save bitrut/7676303 to your computer and use it in GitHub Desktop.
Save bitrut/7676303 to your computer and use it in GitHub Desktop.
Desired Angular model example
var person = new Person({firstName: 'John', lastName: 'Smith'}); // Object created on client side without calling API
var promise = person.save(); // $save()? POST request to API to create the object in backend DB
promise.then(function(success){
alert('ok'); // whatever
});
person.firstName = 'Michael';
promise = person.save(); // PUT request to API to update object in the backend
promise.then(function(success){
alert('ok'); // whatever
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment