Created
November 18, 2016 19:31
-
-
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
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
// 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