Reputation: 32788
My service has the following:
self.$http({
url: xxx,
method: "DELETE"
})
.success((): void => {
});
Is there a way that I can change the state of a button on my html to be disabled while the $http call is in progress?
Upvotes: 0
Views: 53
Reputation: 7688
You can use flag and can call then method of $http. Set flag to true initially, and set it to false in then callback. i.e. the request is completed. Here is a reference for similar question. But you cant check the completion percentage of ajax.
$scope.inprogress=true;//Ajax is in progress
self.$http({
url: self.ac.dataServer + "/api/content/Delete/" + self.content.contentId,
method: "DELETE"
})
.then((): void => {
//Success code here
},():void =>{
//Error handler code here
return true;
}).then(():void =>{
$scope.isProgress=false; //Ajax completed
});
Upvotes: 2