$scope.openDocImg = function(id, e){
var data = [];
...
$http.post("/showDocument", cid).then(function(response){
data = response.data.slice(0);
console.log(data);
});
console.log(data.length); //displays 0
console.log(data);
...
}
I don't get it completely why the data in the post method is filled with content and the outside isn't. Is it because of the variable scope inside and outside the function?
And how do I copy the content to the outer scope?