单击提交按钮后,我需要清除用户写的输入
我不知道我必须在脚本中插入哪些代码来清除它们
<p>
<input type="text" placeholder="name" ng-model="person.name">
</p>
<p>last name: <input type="text" placeholder="last name" ng-model="person.Lname"></p>
<p>phone number: <input type="text" placeholder="number" ng-model="person.number"></p>
<button type="submit" ng-click="sabt()">submit</button>
<table class="table">
<tr>
<th>name</th>
<th>last name</th>
<th>phone number</th>
</tr>
<tr ng-repeat="x in list">
<td>{{x.name}}</td>
<td>{{x.Lname}}</td>
<td>{{x.number}}</td>
</tr>
</table>
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.list=[];
$scope.person={};
$scope.sabt = function(){
$scope.list.push($scope.person);
}
});
最佳答案
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.list=[];
$scope.person={};
$scope.sabt = function(){
$scope.list.push($scope.person);
//CLEAR inputs
$scope.person = {};
}
});
关于javascript - 单击 Angular 提交后如何清除输入,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55664886/