Angular: Reset model
http://angularjs.org/
HTML
<div ng-controller="MyCtrl">
<div ng-repeat="data in datas">
<input type="text" ng-model="data.first_name" />
<input type="text" ng-model="data.last_name" />
</div>
<a ng-click="reset()">Reset to initial value</a>
or
<hr />
<p ng-repeat="data in datas">{{data.first_name}}, {{data.last_name}}, {{data.email}}</p>{{initial}}
JavaScript
function MyCtrl($scope) {
$scope.initial = [
{
first_name : '',
last_name : '',
email : '',
tel : '',
gender : '',
job : '',
age : ''
}
];
$scope.datas = [
{
first_name : 'test',
last_name : 'test',
email : 'test',
tel : '',
gender : '',
job : '',
age : ''
}
];
$scope.reset = function () {
angular.copy($scope.initial, $scope.datas);
}
}