पर बटन अक्षम करना मैंने एक निर्देश लिखा है जो AJAX अनुरोध लंबित होने पर बटन को अक्षम करने में मदद करेगा।एजेक्स अनुरोध
.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;
})
}
}
}])
एचटीएमएल की तरह है::
<button request-pending="pending" ng-disabled="pending">Save</button>
पता करने के लिए यह करने का एक सही तरीका है कि क्या चाहता था
यह मेरा निर्देश है। मैं $ घड़ी
का उपयोग करने से बचना चाहता हूं।