gpt4 book ai didi

javascript - 使用 angularjs 清除输入字段

转载 作者:行者123 更新时间:2023-12-03 05:10:51 26 4
gpt4 key购买 nike

让我重新表述我的问题,我在删除上传的文件时遇到问题,所以我按照建议对我的代码进行了一些修改,但它仍然不起作用,此外还存在覆盖我上传的文件的问题,所以每次我上传一些东西它只会覆盖以前的文件,我希望能够上传很多并删除它们,谢谢

<form class="htmlForm">
<label for="id_payment_proof">{% trans "Payment proof:" %}</label>
<div class="full-size">
<div class="input-control full-size file" data-role="input">
<input id="id_payment_proof" type="file" file-model="payment_proof"/>
<button class="button"><span class="mif-folder"></span></button>
</div>
</div>
<div ng-if="client_invoice.payment_proof_filename">
<a ng-href="{{ client_invoice.payment_proof }}"
ng-bind="client_invoice.payment_proof_filename"
target="_blank"></a>
<button class="button" ng_click="clearInvoice()">
<span class="mif-bin"></span>
</button>
</div>
{% endverbatim %}
</form>

Controller :

editInvoiceHandler = (event, row) ->
$scope.payment_proof = undefined
$scope.htmlFormEl.reset()
$scope.row = row
$scope.client_invoice = row.data()
hasChanges = false
$scope.editMode = true
$scope.$digest()

$scope.clearInvoice() = () ->
$scope.payment_proof = 0

最佳答案

我没有测试下面的代码,但认为它可能与您需要的类似:

$scope.payment_proof = []; // presume you don't want any pre-loaded entries
$scope.add(new_entry) = payment_proof.push(new_entry);
$scope.delete(index) = payment_proof.splice(index,1);
$scope.clearInvoice = { $scope.payment_proof = []; }
//Then submit the payment_proof to the back end

这个想法是操作一个数组(在您的例子中是 payment_proof )并将其提交到后端。

关于javascript - 使用 angularjs 清除输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41826853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com