There is an alternative to disabling the button:
Throttle the execution of web requests.
Underscore has great utils to do that. The method is called throttle()
.
Example:
var getData = function () {
app.state.get = true;
$http({
url: '/api/TestData',
method: "GET"
}).success(function (result) {
app.state.get = false;
});
};
this.retrieve = _.throttle(getData, 1000);
Now, the method will only be executed at most once per second, no matter how often someone clicks on the button. The first request will be made immediately.