Can any one suggest an easy way to reset or reload an HTML form on click event in AngularJS?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use angular.copy({},yourform) to copy empty array to your form object as below
$scope.resetForm = function(form) {
angular.copy({}, form);
}
Html
<form>
<input type="text" ng-model="myForm.myName" />
<input type="text" ng-model="myForm.adress" />
<input type="button" value="reset" ng-click="resetForm(myForm)" />
</form>
Working fiddle