Skip to content

Instantly share code, notes, and snippets.

@leonardo403
Created October 6, 2014 21:00
Show Gist options
  • Save leonardo403/2cfd4be047cfd61e269d to your computer and use it in GitHub Desktop.
Save leonardo403/2cfd4be047cfd61e269d to your computer and use it in GitHub Desktop.
A Pen by Leonardo Lima.
<html ng-app>
<head>
</head>
<body>
<div ng-controller="Controller">
<form novalidate class="simple-form">
Name: <input type="text" ng-model="user.name" /><br />
E-mail: <input type="email" ng-model="user.email" /><br />
Gender: <input type="radio" ng-model="user.gender" value="male" />male
<input type="radio" ng-model="user.gender" value="female" />female<br />
<button ng-click="reset()">RESET</button>
<button ng-click="update(user)">SAVE</button>
</form>
<pre>form = {{user | json}}</pre>
<pre>master = {{master | json}}</pre>
</div>
</body>
</html>
function Controller($scope) {
$scope.master = {};
$scope.update = function(user) {
$scope.master = angular.copy(user);
};
$scope.reset = function() {
$scope.user = angular.copy($scope.master);
};
$scope.reset();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment