1
$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);
}
如何使用function x
作爲$ http.get的回調?或者有沒有其他方法可以確保只有在接收到fetchQA
中的數據後才能執行x()?
當u把它像!我想知道爲什麼我沒有想到它! :) –
@SangramSingh - 隨時都會發生,特別是當你開始思考異步時。 :d – tymeJV