I have this block of codes in my controller..
controller('ChallengeCtrl',function($scope,$http){
$scope.challenged = [];
$scope.checkVideo = function (video) {
var response;
console.log(url);
return $http.get(url).success(function(data) {
return data;
}).error(function(data){
return data;
});
}
$scope.challengeMe = function() {
$scope.checkVideo($scope.selectedVideo).then(function(data){
$scope.challenged = data.data;
console.log($scope.challenged); //working
});
}
$scope.printChallenge = function() {
console.log($scope.challenged); //not working, returns [] null
}
});
I assigned the value of $scope.challenged
when i call challengeMe()
function and I tried to console out the values inside $scope.challenged
array on my printChallenge()
function, but it returns to be null.