I have a promise and I need to call a function in my $scope. If I call the function outside the then it works but actually I need to call it after the promise has been resolved, inside the then. Unfortunately the $scope is unavailable at that stage
traverseTree(items).then(function(data){
$scope.$apply(function () {
$scope.myArray.push(data);
});
});
I didn't find any solution to this problem, actually I don't even know what keywords to use for searching a solution online
EDIT
Here the stacktrace, the exception get thrown at $scope.$apply
$scope looks valorized correcly inside the then
