Let's say I have a model given by $resource. I want to maintain a cache of what has changed and not, so I can:
- easily revert back to pristine mode (discard changes)
- send only changed items (e.g. using
PATCH
)
This is discussed a bit here: Partial Updates (aka PATCH) using a $resource based service?
It is easy to extend $resource
to have other methods, e.g. $patch
and getDirty()
or getChanged()
. But for this to work, I need to catch the original fields when loaded, so I know their clean state.
How can I capture the originally loaded fields?
My intent was to have it stored somewhere on the object itself.
Also open to better ideas.