This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$resource: enumerability of methods and properties, toJSON
#14637
Labels
Milestone
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
If I want to apply some transformations to a
Resource
instance, I could encounter some nasty surprises:doSomethingWithPairs
receives an array of pairs that contains["$promise", /*...*/]
and["$resolved", /*...*/]
.doSomethingElse
contains entries for all instance methods (!) such as$get
,$query
, etc.What is the expected behavior?
This is a weird interaction with Underscore defaults[1] that is not for Angular to fix. However, I do think that some things that could be improved:
$promise
and$resolved
non-enumerable properties ofResource
instances.Resource
instance methods non-enumerable (a la ES6 classes).Resource.prototype.toJSON
method.The latter is the workaround I have used to get a "normal" object from a
Resource
instance, although I would feel more confident if it were documented.Other information (e.g. stacktraces, related issues, suggestions how to fix)
Related issues:
[1] Lodash only includes own, enumerable properties for
omit
.The text was updated successfully, but these errors were encountered: