Reputation: 93
how to disable submit button in angularJs to prevent duplicate response from service.
I am new to angularJs and also this should be supported in IE 8.
Upvotes: 2
Views: 1401
Reputation: 5899
The following approach works for me.
View:
<button ng-disabled="isBusy" ng-click="buttonClick()">Load</button>
Controller:
$scope.buttonClick = function () {
$scope.isBusy = true;
service.getData()
.success(function (data) {
// Use the data
})
.error(function (data, status, headers, config) {
// Log the error
})
.finally(function () {
$scope.isBusy = false;
});
}
Upvotes: 4