0
是呼叫服务“flightPricerequest”如何将服务转化为异步服务在下面angularjs
$scope.flight.blockNow= function(offer,metaData){
SearchFlightsServices.flightPricerequest($scope,offer,metaData);
}
这里是我的服务功能:
var flightPricerequest=function($scope,offer,metadata){
var url = webroot + 'flights/pricerequest';
$scope.data = {
"type" : "json",
"Search_cretaria" : $scope.flight.search,
"selectedOffer" : offer,
"Metadata" : metadata,
"EchoToken" : $scope.flight.EchoToken
};
$http.post(url, $scope.data).success(function(data, status, headers, config) {
if(data.Error){
$scope.flight.error=data.Error;
$scope.sendErrorMessage($scope.flight.error);
return false;
}else{
if(data == true){
window.location = webroot+"flights/book";
}
}
}).error(function(data, status, headers, config) {});
}
我想这种服务转化为异步服务,所以在执行服务时,我可以退出请求,如刷新页面应停止服务,现在所有操作都在服务完成后发生。
它仍然没有工作对我来说,如果我在其他的链接点击,而HTTP的执行也不会工作 – Pravin