Code related to blogpost http://evgmya.blogspot.com/2015/11/angular-handling-promise-status-with-filter.html
Suppose you have a controller action
function SubmitController($http) {
var vm = this;
vm.submitData = function() {
return $http.post('....')
.then(function() {
//Doing something usefull
});
}
}
And you want to disable a button that triggers the action and also show some progress. So using the filter your template will look like this
<button
ng-disabled='status.inProgress'
ng-click='status = (vm.submitData() | promiseStatus)'>Submit</button>
<span class='ng-hide' ng-show='status.inProgress'>Submitting...</span>
<span class='ng-hide' ng-show='status.resolved'>Submitted succsssfully!</span>
<span class='ng-hide' ng-show='status.rejected'>Failed to submit!</span>