我想使用 formdata.entries 函数打印表单数据值?原因是我有多个 ng-repeat。
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Coupon Code</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="coupon in coupons" class="{'fadeOut' : coupon.done}">
<td>{{coupon.title}} <span class="fa fa-close margin-left" ng-click="deletecoupon($index)"></span>
</td>
</tr>
</tbody>
</table>
<div name="couponsFrm">
<input type="text" name="newcoupon" ng-model="newcoupon" required />
<button ng-disabled="couponsFrm.$invalid" ng-click="addcoupon()" class="btn btn-primary">Add Coupon</button>
</div>
这是 Controller
$scope.submitTrType = function(){
var formData = new FormData("#my-form");
console.log(formData);
formData.append('key1', 'value1');
formData.append('key2', 'value2');
for(var pair of formData.entries()) {
console.log(pair[0]+ ', '+ pair[1]);
}
}
最佳答案
试试这个:
for (var value of formData.values()) {
alert(value);
}
关于javascript - 如何使用表单数据打印值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45011264/