Skip to content

Instantly share code, notes, and snippets.

@jarcoal
Created November 18, 2016 19:31
Show Gist options
  • Save jarcoal/7bd754fb909545c39f02f80ced826a50 to your computer and use it in GitHub Desktop.
Save jarcoal/7bd754fb909545c39f02f80ced826a50 to your computer and use it in GitHub Desktop.
Technique to remove a record from a restmod collection without waiting for a server response
// Create mixin to extend Records with a custom destroy method
app.factory('restmodDestroyMixin', function(restmod) {
return restmod.mixin({
$extend: {
Record: {
$destroyImmediately: function() {
this.$scope.$remove(this);
return this.$destroy();
},
}
}
});
});
// Configure restmod to use the mixin
app.config(function(restmodProvider) {
restmodProvider.rebase('restmodDestroyMixin');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment