私はAngularの新機能です。ボタンクリックからAjax呼び出しをキャンセルする方法を理解しようとしています。私は次のコードを書いて、それをさらに追加する方法を教えてください。 あらかじめありがとうございます... !!!
HTML
<a ng-click="cancelCall()" id="pods-cancel-search-button" title="Cancel" class="form-button primary" ><i class="fa fa-search fa-fw"></i>Cancel Search</a>
サービス
paymentSearchApp.service('paymentSearchResponse',['$http', '$log', function($http, $log){
//var response = [];
return {
findResponse: (function(data){
return $http({
url:'data/result.json',
data:data,
dataType: 'JSON',
contentType: 'application/json; characterset=utf-8',
method: 'POST'
}).then(function(resp){
var response = resp;
return response.data;
},function(resp){
$log.error("ERROR occured");
});
})
};
return paymentSearchResponse;
}]);
コントローラ
paymentSearchApp.controller('paymentSearchCtrl', function (paymentSearchService,paymentSearchResponse, $scope) {
paymentSearchResponse.findResponse(requestPayLoadPacked).then(
function(response){
//operation on response
},function(){
alert("error in getting response from payment search service");
}
$scope.cancel = function(){
alert("cancel ajax call");
}
);
});
ありがとう、これは私の問題を解決しました.. !!!! –