简体   繁体   English

如何清除angular.js中的html表单?

[英]How can I clear an html form in angular.js?

I have an add product form. 我有一个添加产品表格。 When user submits it, I want to present him new add product form with reset values. 用户提交时,我想向他展示带有重置值的新添加产品表单。 How can I achieve this is angularjs? 我怎样才能做到这就是angularjs?

Something like this. 这样的事情。

HTML: HTML:

<form ng-submit="submit()">
  <input type="text" ng-model="product.name">
  <input type="submit" value="Submit">
</form>

Controller: 控制器:

$scope.product = {
  name: 'My product'
};

$scope.submit = function() {
  // process the product data

  // Reset the product on the scope
  // which clears the form
  $scope.product = {};
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM