Created
February 25, 2015 08:46
-
-
Save ringoluo/79648ba793787e860e11 to your computer and use it in GitHub Desktop.
AngularJS Rollback value with ng-change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.$watch('color', function(newValue, oldValue) { | |
$scope.previousColor = oldValue; | |
}); | |
$scope.changeColor = function(){ | |
$http.put('...', {color: $scope.color}).error(function(){ | |
$scope.color = $scope.previousColor; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment