I am using angular js for my project. Currently I am getting data using below function. This is my function.
$scope.loadMoreDetails = function () {
$http({
method: "GET",
url: appConfig.apiUrl + "/results/" + $scope.resultId + "/details/"
}).then(function (response) {
$scope.sourceData = response.data.sources;
$scope.sourceList = $scope.sourceData.split(', '); // split string on comma space
console.log($scope.sourceList);
}, function (response) {
$log.error(response);
});
};
My console log inside the function is working well, but I am trying to access that $scope.sourceList
in another function.
$scope.saveAp = function () {
console.log($scope.sourceList)
}
This console.log is undefined. Actually I need to know, how I access $scope.sourceList
outside the function. How I do it.