`plain()` doesn't remove custom methods

Author: giladbeeriCreated Aug 16, 2015Updated Nov 5, 2018

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.