I'm trying copy all $rootScope.$$childTail of Angular for save in variable. How can I this?
I have this code:
var newObject = JSON.stringify($rootScope.$$childTail, function(key, value) {
if((key.indexOf("$") === -1 || key === '$$childTail') && typeof value !== 'function'){
// Store value in our collection
cache.push(value);
}
return value;
}
});
But when I have circular references in the object returned the error: "Converting circular structure to json angular".
If add the code:
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
This remove items of my $rootScope.$$childTail object.
¿Any idea?
THANK YOU!!!!