following the DRY principal, i want to write a button directive which keeps button disabled for the duration of $http class.
I want to do this so as to forbid user from
You can use this in the run block. This will make sure all the buttons will be disabled whenever there is an active XHR call.
myApp.run(function($rootScope, $http) {
$http.defaults.transformRequest.push(function (data) {
$rootScope.progress = true;
return data;
});
$http.defaults.transformResponse.push(function(data){
$rootScope.progress = false;
return data;
})
});
And then use the same model anywhere you want.