-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Proposal for angular.copy supporting circular references #7592
Comments
While having that var cloneBike = myBike.clone();
// or
var cloneBike = Vehicle.clone(myBike) You can view the functions exposed on the |
@rodyhaddad - precisely, the exact issue here is that The problem this presents is that any Angular application can only ever support objects with no circular references. This is the 'unnecessary restriction' I refer to in my original post. So I'm really arguing for this change because I can't control all of the places where This change is backwards compatible and puts the onus on the developer to 'get it right' Very happy to raise a PR with tests etc if that helps. |
@myitcv good call. It's good to note though that the js statement you linked to only gets called when objectEquality is turned on, which should be avoided whenever possible because of performance. |
@rodyhaddad - thanks. And thanks for the note on Incidentally, I also asked this question about an error in the docs which I think is related. Thoughts on that? |
@rodyhaddad - raised a PR for the doc change I also have a branch with a first cut at the changes required for |
I believe this is closed by #7618 |
For anyone else googling this, here is one workaround you might find useful:
|
#2618 and various other posts have explored and explained why Angular current does not support the copying of objects with circular references. I believe this is an unnecessary restriction and so would like to make a proposal.
The proposal is simple. Modify
angular.copy
such that:(The choice of
$clone
as the function name is intentional)This then allows the developer to explicitly add support on objects that contain circular references.
Thoughts?
The text was updated successfully, but these errors were encountered: