I am having a recursive function in some service class to remove some json elements and once they are removed I have to call the callbacks registered for the updates.
My Code -
var trimTree = function(){
removeScripts(tree.children).then(function(){
angular.forEach(callbacks, function(callback){
//console.log(callback);
console.log("Calling callbacks");
callback();
});
});
}
function removeScripts(nodes){
for(i=0;i<nodes.length;i++){
if(nodes[i].type == 'script'){
return nodes.splice(i, 1);
}else{
return removeScripts(nodes[i]);
}
}
}
But its giving me error as TypeError: Cannot read property 'then' of undefined
Thanks
syncoperations...