disabling button while ajax request
问题 I have written a directive which would help disabling a button while ajax requests are pending. this is my directive : .directive('requestPending', ['$http', function ($http) { return { restrict: 'A', scope: { 'requestPending': '=' }, link: function (scope, el, attr) { scope.$watch(function () { return $http.pendingRequests.length; }, function (requests) { scope.requestPending = requests > 0; }) } } }]) the html is like : <button request-pending="pending" ng-disabled="pending">Save</button>