This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$resource and resource.$reset() to pristine state #9457
Open
Description
I have often come across use cases where I want to be able to reset a resource back to its pristine state as it came from the server or other data source, not just a form. Of course, a form would inherit it due to 2-way binding.
Thus, I can do:
// in data source
user = {name:"John",age:35};
// in angular
User.get('123',function(user){
// user.name is now "John"
user.name = "Steve"; // or perhaps it was set in a form, etc.
// user.name is now "Steve"
user.$reset();
// user.name is now "John"
});;
I simply created my own wrapper to it, and call my Resource
which itself calls $resource
, but is this of interest for a PR?
Of course, if this functionality already exists in ngResource and I missed it, happy to just use that. :-)