Skip to content

Instantly share code, notes, and snippets.

@codeskyblue
Created June 18, 2015 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeskyblue/594e81b10afcfe15d5e2 to your computer and use it in GitHub Desktop.
Save codeskyblue/594e81b10afcfe15d5e2 to your computer and use it in GitHub Desktop.
Button: Edit --> Saving --> Saved
<!DOCTYPE html>
<html>
<head>
<script src="bower_components/angularjs/angular.min.js"></script>
<style>
.button {
margin: 0;
padding: 5px 10px;
min-width: 54px;
font-size: 13px;
border-radius: 4px;
border: none;
box-shadow: inset 0 0 0 1px purple;
background-color: #fff;
color: purple;
}
</style>
</head>
<body ng-app="myApp">
<div ng-controller="MainCtrl">
<button class="button" ng-disabled="!saveButtonEnable" ng-click="saveEnv()">{{saveButtonText}}</button>
</div>
</body>
<script>
angular.module('myApp', []).controller("MainCtrl", function($scope, $timeout){
$scope.saveButtonText = "Edit";
$scope.saveButtonEnable = true;
$scope.saveEnv = function(){
$scope.saveButtonText = "Saving ...";
$scope.saveButtonEnable = false;
$timeout(function(){
$scope.saveButtonText = "Saved";
}, 1000);
$timeout(function(){
$scope.saveButtonText = "Edit";
$scope.saveButtonEnable = true;
}, 1500);
};
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment