Angular has a built-in feature that removes properties with a prefix of $$
from request data or params objects.
I want to filter out my own UI-specific properties that I don't want to send to the server, but I don't want to rely on using $$
.
Is there a way to access Angular's $$
filter method publicly to filter objects with a different prefix?
Where would be the most appropriate place to implement this method? Should I use a Transform or an Interceptor?
For example, consider the following data object:
var payload = {
id: 12345,
name: 'Bob',
_editing: true
};
When sending this object to the server like this:
$http({
method: 'POST',
url: '/save',
data: payload
});
How can I remove the _editing
property before the request is sent?
EDIT: Or any property starting with _
This filter should apply to all requests and should be able to handle deep, complex objects.
I am using Angular v1.3.18
Thank you!