The question is simple, before the function I declare splited
and within the function change splited
to the value returned in response
, now, after the function when I give console.log
returns empty. Why?
var splited;
$scope.id = $routeParams.id;
shows.get($scope.id).then(function(response) {
// splita url video to get only video id
var video = response.video_url;
splited = video.split("=")[1];
});
console.log(splited);