Reputation: 7191
$scope.fetchQA = function() {
$scope.url = 'js/jsons/QA.json';
$http({method: 'GET', url: $scope.url}).
success(function(data, status, headers, config) {
$scope.QA = data;
});
}
$scope.fetchQA();
function x(){
alert(QA);
}
How do i use function x
as a callback for $http.get? or is there any other way to ensure that x() will get executed only after reception of data in fetchQA
?
Upvotes: 1
Views: 1921
Reputation: 104775
Put it in the callback right after your logic:
$http({method: 'GET', url: $scope.url}).
success(function(data, status, headers, config) {
$scope.QA = data;
x();
});
Upvotes: 2