I have two buttons labeled "Save" and "Saving..."
<div ng-switch on="isLoading">
<div ng-switch-when="true">
<button type="button" class="btn btn-primary btn-block disabled">Saving ...</button>
</div>
<div ng-switch-when="false">
<button type="submit" class="btn btn-primary btn-block" ng-disabled="!allowSubmit(addUser)" ng-click="add();">Save</button>
</div>
</div>
My goal is to keep the button as 'Save' until the user clicks it, at which point it will change to 'Saving...' for a brief moment. I attempted using $timeout but it ended up delaying the entire form submission by 2 seconds.
$dialogScope.add = function() {
if ($dialogScope.user.password != $dialogScope.user.confirmpassword && $dialogScope.user.username) {
$dialogScope.hasError = true
$dialogScope.errorMessage = "Password does not match";
return $dialogScope.errorMessage;
}
var copy = angular.copy($dialogScope.user);
}
$timeout(function() {
$dialogScope.hasError = false;
$scope.users.push(copy);
$dialogScope.closeThisDialog();
}, 2000);
Any suggestions on how to achieve this without delaying the form submission?