0
var count = 0;
getColumns($scope);
function getColumns(tmp) {
    EmpApi.getExtraColumns().success(function (cols) {
        $scope.cols = cols;
        count = Object.keys($scope.cols).length;
        console.log(count);     

    }).error(function (error) {
        $scope.status = "unable to load columns";
    })
}
console.log(count);  

I am trying to update my count variable with the code above. It is in a controller. In getExtraColumns function console.log prints the right value of count. but the second count in the outer scope still prints 0. How do I solve this issue?

Thunfische
  • 1,107
  • 2
  • 15
  • 35

0 Answers0