anna
anna

Reputation: 93

Disable submit button in AngularJS

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

Answers (1)

Sergey Kolodiy
Sergey Kolodiy

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

Related Questions