I have a button that does some async request, such as
<button ng-click="loadStuff()">Load stuff</button> where the fuction might look something like this
$scope.loadStuff = function() {
$http("/foo").success(function(response) {
// some stuff
});
}
And I want my button to show "loading" text and be disabled while the request is in progress ... but I don't know how can I access it. In pseudocode it would be something like
$scope.loadStuff = function() {
button = getTehButtonSomehow();
// in twitter bootstrap speak this is soemthing like .text("loading").prop("disabled", "disabled")
button.button("loading") ;
$http("/foo").success(function(response) {
// some stuff
// restore the original state
button.button("reset");
}).failure(function() {
});
}
Would it be possible to have a directive that would do this by just adding a "loading" attribute to the button?
Like <button ng-click="loadStuff()" loading-text="loading some stuff ...">Load stuff</button> which would automatically handle the state changes.