#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:
function copy(source, destination){
if (isWindow(source) || isScope(source)) {
throw ngMinErr('cpws',
"Can't copy! Making copies of Window or Scope instances is not supported.");
}
// ***** ADD THESE LINES ****
if (source && (source.$clone != null)) {
return source.$clone(destination);
}
// ....
(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?
#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.copysuch that:(The choice of
$cloneas the function name is intentional)This then allows the developer to explicitly add support on objects that contain circular references.
Thoughts?