`plain()` doesn't remove custom methods
I have a Restangular object returned from server, it has several Restangular methods, server data and one custom method that I added using addRestangularMethod().
After calling plain() on the object, the original Restangular properties are removed, but the custom one isn't. I would like to be able to get a raw JSON object - the raw response from the server (or after applying interceptors, it doesn't matter in my case). Because plain() doesn't do the job perfectly, currently I use something like angular.fromJson(angular.toJson(res.plain())) which removes also the custom method left after plain.
Hi. If you don't want to see your custom methods in response, you can simply check if there is a request or response. For e.g.:
RestangularProvider.setOnElemRestangularized(function (elem, isCollection, what, ra) { if (!elem.fromServer) { elem.YOUR_CUSTOM_METHOD = function () { ... }; } return elem; });